public async Task <TResponse <PageResult <ApiEndpointRes> > > GetPaging(GetApiEndpointReq req) { try { if (req.Page <= 1) { req.Page = 1; } if (req.PageSize <= 5) { req.PageSize = 5; } var result = await _readOnlyRepository.QueryMultipleLFAsync <ApiEndpoint, int>( SqlQuery.API_ENDPOINT_GET_PAGING, new { Name = $"%{req.Name}%", Controller = $"%{req.Controller}%", Action = $"%{req.Action}%", Method = $"%{req.Method}%", Skip = (req.Page - 1) * req.PageSize, Take = req.PageSize }); if (result != null) { if (result.IsSuccess) { return(await Ok(new PageResult <ApiEndpointRes>(req.Page, req.PageSize, result.Data.Item2, Mapper.Map <IEnumerable <ApiEndpointRes> >(result.Data.Item1)))); } return(await Fail <PageResult <ApiEndpointRes> >(result.Message)); } return(await Ok(new PageResult <ApiEndpointRes>(1, req.PageSize, 0, null))); } catch (Exception exception) { return(await Fail <PageResult <ApiEndpointRes> >(exception)); } }
public async Task <TResponse <PageResult <UserRes> > > GetPaging(GetUserReq 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_PAGING, new { Username = $"%{req.Username}%", Skip = (req.Page - 1) * req.PageSize, Take = req.PageSize }); 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)); } }