/// <summary> /// Get User By Paging /// </summary> /// <param name="req"></param> /// <returns></returns> public async Task <TResponse <PageResult <UserModel> > > GetPaging(GetUserByPagingModel req) { try { if (req.Page <= 1) { req.Page = 1; } if (req.PageSize <= 5) { req.PageSize = 5; } var result = await ReadOnlyRepository.QueryMultipleLFAsync <UserModel, int>( string.Format(SqlQuery.USER_GET_PAGING, req.ColumnOrder, req.SortDir), new { Username = $"%{req.Username}%", Skip = (req.Page - 1) * req.PageSize, Take = req.PageSize }); if (result != null) { if (result.IsSuccess) { return(await Ok(new PageResult <UserModel>(req.Page, req.PageSize, result.Data.Item2, result.Data.Item1))); } return(await Fail <PageResult <UserModel> >(result.Message)); } return(await Ok(new PageResult <UserModel>(1, req.PageSize, 0, null))); } catch (Exception exception) { return(await Fail <PageResult <UserModel> >(exception)); } }
public async Task <ActionResult <PageResult <UserModel> > > Get([FromQuery] GetUserByPagingModel req) { return(Ok(await _userService.GetPaging(req))); }