Adding
This commit is contained in:
+458
@@ -0,0 +1,458 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LCU.Library.Internal.IncentiveApiModels.Entities
|
||||
{
|
||||
public class Role
|
||||
{
|
||||
[Required]
|
||||
[StringLength(255, MinimumLength = 2)]
|
||||
public string Name { get; }
|
||||
|
||||
public string Description { get; }
|
||||
public IReadOnlyCollection<Permission> Permissions { get; }
|
||||
public bool HasCommissions { get; }
|
||||
public int Rank { get; }
|
||||
public bool CanBeAssigned { get; }
|
||||
|
||||
private Role(
|
||||
string name,
|
||||
string description,
|
||||
List<Permission> permissions,
|
||||
bool hasCommissions,
|
||||
int rank = 1,
|
||||
bool canBeAssigned = true
|
||||
)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
Permissions = permissions;
|
||||
HasCommissions = hasCommissions;
|
||||
Rank = rank;
|
||||
CanBeAssigned = canBeAssigned;
|
||||
}
|
||||
|
||||
public static List<Role> GetRolesList()
|
||||
{
|
||||
return typeof(Role).GetFields(BindingFlags.Public | BindingFlags.Static)
|
||||
.Where(field => field.FieldType == typeof(Role))
|
||||
.Select(field => (Role)field.GetValue(field))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static List<Role> SearchRoles(string term)
|
||||
{
|
||||
term = term.ToLower().Trim();
|
||||
return GetRolesList()
|
||||
.Where(role => role.Name.ToLower().Contains(term) ||
|
||||
role.Description.ToLower().Contains(term))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public static Role DetermineRoleOrDefault(string role)
|
||||
{
|
||||
return GetRolesList().FirstOrDefault(r => r.Name.Equals(role)) ?? UNKNOWN_ROLE;
|
||||
}
|
||||
|
||||
public static readonly Role SystemAppUser = new(
|
||||
"SystemAppUser",
|
||||
"System App User", new List<Permission>(),
|
||||
false,
|
||||
0,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly Role Admin = new(
|
||||
"Admin",
|
||||
"Admin",
|
||||
Permission.GetAllPermissions(true),
|
||||
false,
|
||||
99
|
||||
);
|
||||
|
||||
public static readonly Role BusinessLineManager = new(
|
||||
"BusinessLineManager",
|
||||
"Business Line Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.ManageDepartmentGoals,
|
||||
Permission.ManagePersonnelGoals,
|
||||
Permission.ViewPerformanceForBusinessLine,
|
||||
Permission.ViewPerformanceForRegion
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
98
|
||||
);
|
||||
|
||||
public static readonly Role RegionalManager = new(
|
||||
"RegionalManager",
|
||||
"Regional Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.ManageDepartmentGoals,
|
||||
Permission.ViewPerformanceForRegion
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
97
|
||||
);
|
||||
|
||||
public static readonly Role Manager = new(
|
||||
"Manager",
|
||||
"Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.ManagePersonnelGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
96
|
||||
);
|
||||
|
||||
public static readonly Role MortgageManager = new(
|
||||
"MortgageManager",
|
||||
"Mortgage Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.ManagePersonnelGoals,
|
||||
Permission.EligibleForReferrals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
96
|
||||
);
|
||||
|
||||
public static readonly Role BM = new(
|
||||
"BM",
|
||||
"Branch Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
Permission.ManagePersonnelGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
96
|
||||
);
|
||||
|
||||
public static readonly Role InStoreBranchManager = new(
|
||||
"InStoreBranchManager",
|
||||
"In-Store Branch Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
96
|
||||
);
|
||||
|
||||
public static readonly Role ABM = new(
|
||||
"ABM",
|
||||
"Assistant Branch Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
Permission.ManagePersonnelGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
95
|
||||
);
|
||||
|
||||
public static readonly Role InStoreAssistantBranchManager = new(
|
||||
"InStoreAssistantBranchManager",
|
||||
"In-Store Assistant Branch Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
95
|
||||
);
|
||||
|
||||
public static readonly Role ManagementTrainee = new(
|
||||
"ManagementTrainee",
|
||||
"Management Trainee",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
Permission.ManagePersonnelGoals
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList()
|
||||
.Concat(Permission.DepartmentManagerPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
95
|
||||
);
|
||||
|
||||
public static readonly Role MSCTeamLead = new(
|
||||
"MSCTeamLead",
|
||||
"Member Service Center Team Lead",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.AssignAssociatesToDepartment,
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
Permission.ViewReports,
|
||||
Permission.ViewActivityReport,
|
||||
Permission.ViewGoalProgressReport,
|
||||
Permission.ViewPerformanceForDepartment
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
95
|
||||
);
|
||||
|
||||
public static readonly Role BOM = new(
|
||||
"BOM",
|
||||
"Branch Operations Manager",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.AssignAssociatesToDepartment,
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
Permission.ViewReports,
|
||||
Permission.ViewActivityReport,
|
||||
Permission.ViewGoalProgressReport,
|
||||
Permission.ViewPerformanceForDepartment,
|
||||
Permission.TransferActivitiesBetweenAssociates,
|
||||
Permission.TransferActivitiesBetweenDepartments
|
||||
}
|
||||
.Concat(Permission.BaselinePermissions())
|
||||
.Concat(Permission.TransferApprovalPermissions())
|
||||
.Concat(Permission.TransferRejectionPermissions())
|
||||
.Concat(Permission.TransferRequestPermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
94
|
||||
);
|
||||
|
||||
public static readonly Role MSLO = new(
|
||||
"MSLO",
|
||||
"Member Services Loan Officer",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
93
|
||||
);
|
||||
|
||||
public static readonly Role PFO = new(
|
||||
"PFO",
|
||||
"PERS FIN OFFICER",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
93
|
||||
);
|
||||
|
||||
public static readonly Role UniversalSpecialistPFO = new(
|
||||
"UniversalSpecialist-PFO",
|
||||
"Universal Specialist - PFO",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
93
|
||||
);
|
||||
|
||||
public static readonly Role UniversalSpecialistTeller = new(
|
||||
"UniversalSpecialist-Teller",
|
||||
"Universal Specialist - Teller",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
93
|
||||
);
|
||||
|
||||
public static readonly Role LIC = new(
|
||||
"LIC",
|
||||
"Landmark Investment Center",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.ViewPerformanceForDepartment,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role Mortgage = new(
|
||||
"Mortgage",
|
||||
"Mortgage",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role Teller = new(
|
||||
"Teller",
|
||||
"Teller",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role ConsumerLoanCoordinator = new(
|
||||
"ConsumerLoanCoordinator",
|
||||
"Consumer Loan Coordinator",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role LicAdmin = new(
|
||||
"LicAdmin",
|
||||
"LIC Admin",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.SetActivityToAcceptedFromRejected,
|
||||
Permission.SetActivityToManualReviewFromRejected,
|
||||
Permission.SetActivityToRejectedFromAccepted,
|
||||
Permission.SetActivityToRejectedFromManualReview,
|
||||
Permission.TransferActivitiesBetweenAssociates,
|
||||
Permission.TransferActivitiesBetweenDepartments
|
||||
}
|
||||
.Concat(Permission.BaselinePermissions())
|
||||
.Concat(Permission.TransferApprovalPermissions())
|
||||
.Concat(Permission.TransferRejectionPermissions())
|
||||
.Concat(Permission.TransferRequestPermissions())
|
||||
.ToList(),
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly Role MSR = new(
|
||||
"MSR",
|
||||
"Member Services Representative",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role OpsHelpDesk = new(
|
||||
"OpsHelpDesk",
|
||||
"Ops Help Desk",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true
|
||||
);
|
||||
|
||||
public static readonly Role ManagementTraineePFO = new(
|
||||
"ManagementTrainee-PFO",
|
||||
"Management Trainee - PFO",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.EligibleForReferrals,
|
||||
Permission.HaveSalesGoals,
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
true,
|
||||
-1,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly Role UNKNOWN_ROLE = new(
|
||||
"UNKNOWN",
|
||||
"Base role has no access",
|
||||
new List<Permission>(),
|
||||
false,
|
||||
0,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly Role MISSING_ROLE = new(
|
||||
"MISSING",
|
||||
"User base role unknown.",
|
||||
new List<Permission>(),
|
||||
false,
|
||||
0,
|
||||
false
|
||||
);
|
||||
|
||||
public static readonly Role Developer = new(
|
||||
"Developer",
|
||||
"Developer",
|
||||
new List<Permission>()
|
||||
{
|
||||
Permission.AccessTestEnvironments
|
||||
}.Concat(Permission.BaselinePermissions())
|
||||
.ToList(),
|
||||
false,
|
||||
0,
|
||||
false
|
||||
);
|
||||
|
||||
public static List<Role> DepartmentManagerRoles => new()
|
||||
{
|
||||
ABM,
|
||||
BOM,
|
||||
BM,
|
||||
BusinessLineManager,
|
||||
InStoreAssistantBranchManager,
|
||||
InStoreBranchManager,
|
||||
ManagementTrainee,
|
||||
Manager,
|
||||
MortgageManager,
|
||||
RegionalManager
|
||||
};
|
||||
|
||||
public static List<Role> LeadershipRoles => new()
|
||||
{
|
||||
BusinessLineManager,
|
||||
RegionalManager
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user