public async Task <PagedResultDto <BloggerListDto> > GetBloggersPagedAsync(GetBloggerInput input) { string[] asc = null, desc = null; Dictionary <string, object> wheres = new Dictionary <string, object>(); if (input.CategoryId.HasValue) { wheres.Add("[CategoryId]=@CategoryId", new { CategoryId = input.CategoryId.Value }); } if (!String.IsNullOrEmpty(input.Title)) { wheres.Add("Title Like @Title", new { Title = "%" + input.Title + "%" }); } switch (input.Order) { case Model.Enum.OrderType.ASC: asc = input.Sorting.Split(','); break; case Model.Enum.OrderType.DESC: desc = input.Sorting.Split(','); break; } var result = await _bloggerRepository.GetPageLoadAsync(wheres, input.Page, input.Limit, asc, desc); return(new PagedResultDto <BloggerListDto>(input.Page, input.Limit, result.totalCount, _mapper.Map <List <BloggerListDto> >(result.items))); }
public async Task <IActionResult> GetPaged([FromQuery] GetBloggerInput input) { PagedResultDto <BloggerListDto> result = await _bloggerService.GetBloggersPagedAsync(input); return(Ok(result)); }