Beispiel #1
0
        public async Task <TResponse <PageResult <UserRes> > > GetByRoleGroupId(GetUserByRoleGroupIdReq req)
        {
            try
            {
                if (req.Page <= 1)
                {
                    req.Page = 1;
                }

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

                var result = await _readOnlyRepository.QueryMultipleLFAsync <User, int>(
                    SqlQuery.USER_GET_BY_ROLE_GROUP, new
                {
                    Username = $"%{req.Username}%",
                    RoleId   = req.RoleGroupId,
                    Skip     = (req.Page - 1) * req.PageSize,
                    Take     = req.PageSize,
                    req.RoleGroupId
                });

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

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

                return(await Ok(new PageResult <UserRes>(1, req.PageSize, 0, null)));
            }
            catch (Exception exception)
            {
                return(await Fail <PageResult <UserRes> >(exception));
            }
        }
 public async Task <ActionResult <RoleGroupRes> > GetUsers([FromQuery] GetUserByRoleGroupIdReq req)
 {
     return(Ok(await _userService.GetByRoleGroupId(req)));
 }