public async Task <List <UserClaimModel> > GetAllUserClaims()
        {
            try
            {
                var userScopeClaims = await _userScopeClaimRepository.GetAllUserScopeClaims();

                List <BusinessModels.UserAccessControl.UserClaimModel> userClaimList =
                    new List <BusinessModels.UserAccessControl.UserClaimModel>();

                foreach (var userScopeClaimModel in userScopeClaims)
                {
                    var scopeClaimModel = await _scopeClaimRepository.GetScopeClaimById(userScopeClaimModel.Id);

                    var claimModel = await _claimRepository.GetClaimById(scopeClaimModel.ClaimId);

                    var userClaim = new BusinessModels.UserAccessControl.UserClaimModel(claimModel.Type, null);

                    userClaimList.Add(userClaim);
                }

                return(userClaimList);
            }
            catch (SqlCustomException e)
            {
                throw new SqlCustomException("No User Claims Found.", e.InnerException);
            }
        }
Beispiel #2
0
        public ClaimBusinessEntities.Claim GetClaimById(int claimId)
        {
            var claim = repository.GetClaimById(claimId);

            if (claim != null)
            {
                return(Mapper.ConverDBToBusinessEntity(claim));
            }
            return(null);
        }
        public async Task <List <ScopeModel> > GetAllScopes()
        {
            try
            {
                var scopes = await _scopeRepository.GetAllScopes();

                List <BusinessModels.UserAccessControl.ScopeModel> scopeList =
                    new List <BusinessModels.UserAccessControl.ScopeModel>();

                foreach (var dataScopeModel in scopes)
                {
                    var scopeModel = ModelConverterService.ConvertTo(dataScopeModel,
                                                                     new BusinessModels.UserAccessControl.ScopeModel());

                    scopeModel.Claims = new List <BusinessModels.UserAccessControl.ClaimModel>();

                    var scopeClaims = await _scopeClaimRepository.GetAllScopeClaims();

                    foreach (var dataScopeClaimModel in scopeClaims)
                    {
                        if (scopeModel.Id == dataScopeClaimModel.ScopeId)
                        {
                            var dataClaimModel = await _claimRepository.GetClaimById(dataScopeClaimModel.ClaimId);

                            var claimModel = ModelConverterService.ConvertTo(dataClaimModel,
                                                                             new BusinessModels.UserAccessControl.ClaimModel());

                            scopeModel.Claims.Add(claimModel);
                        }
                    }

                    scopeList.Add(scopeModel);
                }

                return(scopeList);
            }
            catch (SqlCustomException e)
            {
                throw new SqlCustomException("No Scopes Found.", e.InnerException);
            }
        }