/// <summary>
        ///     Get Site By Paging
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public async Task <TResponse <PageResult <SiteModel> > > GetPaging(GetSiteByPagingModel req)
        {
            try
            {
                if (req.Page <= 1)
                {
                    req.Page = 1;
                }

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

                var result = await ReadOnlyRepository.QueryMultipleLFAsync <SiteModel, int>(
                    string.Format(SqlQuery.SITE_GET_PAGING, req.ColumnOrder, req.SortDir), new
                {
                    Skip = (req.Page - 1) * req.PageSize,
                    Take = req.PageSize
                });

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

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

                return(await Ok(new PageResult <SiteModel>(1, req.PageSize, 0, null)));
            }
            catch (Exception exception)
            {
                return(await Fail <PageResult <SiteModel> >(exception));
            }
        }
Example #2
0
 public async Task <ActionResult <PageResult <SiteModel> > > Get([FromQuery] GetSiteByPagingModel req)
 {
     return(Ok(await _siteService.GetPaging(req)));
 }