public async Task <ActionResult <IEnumerable <IdentityResourcePropertyRes> > > GetProperties([FromQuery] GetIdentityResourcePropertyReq req)
 {
     return(Ok(await _identityResourceService.GetIdentityResourceProperties(req)));
 }
Exemplo n.º 2
0
        public async Task <TResponse <PageResult <IdentityResourcePropertyRes> > > GetIdentityResourceProperties(GetIdentityResourcePropertyReq req)
        {
            try
            {
                if (req.Page <= 1)
                {
                    req.Page = 1;
                }

                if (req.PageSize <= 5)
                {
                    req.PageSize = 5;
                }

                var result = await _readOnlyRepository.QueryMultipleLFAsync <IdentityResourceProperty, int>(
                    SqlQuery.IDENTITY_RESOURCE_PROPERTY_GET_PAGING, new
                {
                    req.IdentityResourceId,
                    Skip = (req.Page - 1) * req.PageSize,
                    Take = req.PageSize
                });

                if (result != null)
                {
                    if (result.IsSuccess)
                    {
                        return(await Ok(new PageResult <IdentityResourcePropertyRes>(req.Page, req.PageSize, result.Data.Item2,
                                                                                     Mapper.Map <IEnumerable <IdentityResourcePropertyRes> >(result.Data.Item1))));
                    }

                    return(await Fail <PageResult <IdentityResourcePropertyRes> >(result.Message));
                }

                return(await Ok(new PageResult <IdentityResourcePropertyRes>(1, req.PageSize, 0, null)));
            }
            catch (Exception exception)
            {
                return(await Fail <PageResult <IdentityResourcePropertyRes> >(exception));
            }
        }