using System; using System.Collections.Generic; using System.Linq; using BO.AppServer.Metadata.Enums; namespace BO.AppServer.Business.Security { internal class RoleUtils { public static IEnumerable GetElevatedRoles(bool isNormalized = false) { return GetRoles(isNormalized, RoleEnum.System, RoleEnum.Console, RoleEnum.Service); } public static IEnumerable GetUserRoles(bool isNormalized = false) { return GetRoles(isNormalized, RoleEnum.User, RoleEnum.Uploader, RoleEnum.Downloader, RoleEnum.Accountant, RoleEnum.Admin); } public static IEnumerable GetAdminRoles(bool isNormalized = false) { return GetRoles(isNormalized, RoleEnum.SuperAdmin,RoleEnum.System); } public static IEnumerable GetSystemRoles(bool isNormalized = false) { return GetRoles(isNormalized, RoleEnum.System, RoleEnum.Console, RoleEnum.B2B, RoleEnum.Service); } public static IEnumerable GetAllRoles(bool isNormalized = false) { var roles = Enum.GetNames(typeof(RoleEnum)); return isNormalized ? roles.Select(x => x.ToUpper()) : roles; } private static IEnumerable GetRoles(bool isNormalized, params RoleEnum[] roles) { if (roles == null) throw new ArgumentNullException(nameof(roles)); if (roles.Length == 0) return Array.Empty(); return isNormalized ? roles.Select(x => x.ToString().ToUpper()) : roles.Select(x => x.ToString()); } } }