public async Task <ClaimsResponse> GetClaimsByRole(string roleId)
        {
            try
            {
                ClaimsResponse claimsResponse = new ClaimsResponse();
                claimsResponse.Claims = new List <ClaimsRow>();
                var claimsIds = await Context.RoleClaims.Where(a => a.RoleId == roleId).Select(a => int.Parse(a.ClaimValue)).ToListAsync();

                var _claims = await Context.Claims.Where(a => claimsIds.Contains(a.Id)).Select(a => a).ToListAsync();

                foreach (var item in _claims)
                {
                    ClaimsRow claimsRow = new ClaimsRow();
                    item.CopyPropertiesTo(claimsRow);
                    claimsResponse.Claims.Add(claimsRow);
                }
                claimsResponse.LstCount = claimsResponse.Claims.Count();
                claimsResponse.ToSuccess <ClaimsResponse>();
                return(claimsResponse);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public async Task <ClaimsResponse> GetListAsync(ListDTO listDTO)
        {
            var response = new ClaimsResponse();

            try
            {
                response = await _claimsRepository.GetClaimListByPaging(listDTO);

                return(response.ToSuccess <ClaimsResponse>());
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Ejemplo n.º 3
0
        public async Task <ClaimsResponse> GetById(int Id)
        {
            try
            {
                var response = new ClaimsResponse();
                response.Claims = new List <ClaimsRow>();
                ClaimsRow claimsRow = new ClaimsRow();
                Claims    result    = await _claimsRepository.GetById(Id);

                if (result != null)
                {
                    result.CopyPropertiesTo(claimsRow);
                    response.Claims.Add(claimsRow);
                }
                return(response.ToSuccess <ClaimsResponse>());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }