public async Task <ActionResult> Index(int?page) { int currentPage = page ?? 1; int quantityOfPostsOnPage = _settingsRepo.GetSettings().PostsOnSite; try { var posts = await _postRepo.GetAllPostsAsync(); return(View(posts.ToPagedList <Post>(currentPage, quantityOfPostsOnPage))); } catch (Exception e) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
public async Task <IActionResult> Get() { var posts = await _postRepo.GetAllPostsAsync(); return(Ok(posts.Select(p => ApiModelConverter.ToPostApiModel(p)))); }
public async Task <ActionResult <PostsWithCountDto> > GetAllPostsAsync([FromQuery] int?pageNumber, int?userId) { var posts = await _repository.GetAllPostsAsync(pageNumber, userId); return(Ok(posts)); }