コード例 #1
0
        static IEnumerable <RoleClaim> GetPreconfiguredRoleClaims(CollegeContext collegeContext)
        {
            var result = new List <RoleClaim>();

            var roles  = collegeContext.Roles.ToList();
            var claims = collegeContext.Claims.ToList();

            var listCliamsForRoleFullAdmin = new List <string>
            {
                Constaints.ClaimAdminisiterAllUsers,
                Constaints.ClaimAdminisiterClaims,
                Constaints.ClaimAdminisiterColleges,
                Constaints.ClaimAdminisiterCollegeUsers,
                Constaints.ClaimAdminisiterHomework,
                Constaints.ClaimAdminisiterRoles
            };

            var listCliamsForRoleCollegeAdmin = new List <string>
            {
                Constaints.ClaimAdminisiterCollegeUsers,
                Constaints.ClaimAdminisiterHomework
            };

            var listCliamsForRoleTeacher = new List <string>
            {
                Constaints.ClaimAdminisiterHomework
            };

            foreach (var role in roles)
            {
                if (role.RoleName == Constaints.RoleFullAdmin)
                {
                    foreach (var claimName in listCliamsForRoleFullAdmin)
                    {
                        var roleClaim = new RoleClaim
                        {
                            Claim = claims.Single(o => o.ClaimName == claimName),
                            Role  = role
                        };
                        result.Add(roleClaim);
                    }
                }

                if (role.RoleName == Constaints.RoleCollegeAdmin)
                {
                    foreach (var claimName in listCliamsForRoleCollegeAdmin)
                    {
                        var roleClaim = new RoleClaim
                        {
                            Claim = claims.Single(o => o.ClaimName == claimName),
                            Role  = role
                        };
                        result.Add(roleClaim);
                    }
                }

                if (role.RoleName == Constaints.RoleTeacher)
                {
                    foreach (var claimName in listCliamsForRoleTeacher)
                    {
                        var roleClaim = new RoleClaim
                        {
                            Claim = claims.Single(o => o.ClaimName == claimName),
                            Role  = role
                        };
                        result.Add(roleClaim);
                    }
                }
            }
            return(result);
        }
コード例 #2
0
 public EfRepository(CollegeContext dbContext)
 {
     _dbContext = dbContext;
 }
コード例 #3
0
 public AppUserRepository(CollegeContext dbContext) : base(dbContext)
 {
 }