aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/Enums/UserRole.cs
blob: 86924b47499155a234a4d793e7c07ca4d37548c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace Quality.Storage.Api.Enums;

public enum UserRole
{
	LEAST_PRIVILEGED = 0,
	ADMIN = 1,
}

public static class UserRoleHelper
{
	public static UserRole FromString(string role) => role switch {
			"least_privileged" => UserRole.LEAST_PRIVILEGED,
			"admin" => UserRole.ADMIN,
			_ => throw new ArgumentOutOfRangeException(nameof(role), role, null)
	};

	public static string ToString(UserRole role) => role switch {
			UserRole.LEAST_PRIVILEGED => "least_privileged",
			UserRole.ADMIN => "admin",
			_ => throw new ArgumentOutOfRangeException(nameof(role), role, null)
	};
}