public async Task <IActionResult> PageAsync([FromRoute] string slug, [FromQuery] int id = 0) { if (string.IsNullOrEmpty(slug) && id <= 0) { return(NotFound()); } Page entity; if (id > 0) { entity = await _pageService.GetByIdAsync(id); } else { entity = await _pageService.FindBySlugAsync(slug); } if (entity == null) { return(NotFound()); } var model = _pageFactory.ToModel(entity, new PageModel()); await SetPageTitleAndMetadataAsync(model); return(View(model)); }
public async Task <ApiPagedListOutput <PageModel> > GetListAsync([FromQuery] ApiListQueryModel model) { var list = await _pageService.GetPagesPagedListAsync(new ListBasicQueryInput() { SearchTerm = model.SearchTerm, Limit = model.Limit, Skip = model.Skip }); return(new ApiPagedListOutput <PageModel>(list.TotalCount, list.Select(t => _pageFactory.ToModel(t, new PageModel())).ToList())); }