aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/Enums/EUserRole.cs
blob: 75a81b388833e0f2f6917c5bb93f6ff8731dbd4c (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 I2R.Storage.Api.Enums;

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

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

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