Skip to content

Commit 3769257

Browse files
committed
adding role objects
1 parent e226845 commit 3769257

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Common;
2+
3+
public enum Role
4+
{
5+
CohortManagerUser,
6+
CohortManagerDummyGpRemoval
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Common;
2+
3+
using System.ComponentModel.DataAnnotations;
4+
5+
public class RoleConfig
6+
{
7+
[Required]
8+
public required string CohortManagerUserWorkgroupId { get; init; }
9+
[Required]
10+
public required string CohortManagerDummyGpRemovalWorkgroupId { get; init; }
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace Common;
2+
3+
using Microsoft.Extensions.Options;
4+
5+
public class RoleMapper
6+
{
7+
private readonly Dictionary<string, Role> _roleMappings;
8+
9+
IOptions<RoleConfig> _roleConfig;
10+
public RoleMapper(IOptions<RoleConfig> roleConfig)
11+
{
12+
_roleConfig = roleConfig;
13+
_roleMappings = new Dictionary<string, Role>
14+
{
15+
{ _roleConfig.Value.CohortManagerUserWorkgroupId, Role.CohortManagerUser },
16+
{ _roleConfig.Value.CohortManagerDummyGpRemovalWorkgroupId, Role.CohortManagerDummyGpRemoval }
17+
};
18+
}
19+
20+
public Role? GetRole(string workgroupId)
21+
{
22+
return _roleMappings.TryGetValue(workgroupId, out var mappedRole) ? mappedRole : null;
23+
}
24+
}

0 commit comments

Comments
 (0)