Created
October 16, 2017 08:52
-
-
Save thangchung/a94095661aef33abd2d86fa9794ab934 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BlogCore.Api.Features.Posts.ListOutPostByBlog; | |
using BlogCore.Core; | |
using BlogCore.Core.Helpers; | |
using BlogCore.PostContext.Core.Domain; | |
using BlogCore.PostContext.UseCases.ListOutPostByBlog; | |
using MediatR; | |
using Microsoft.AspNetCore.Mvc; | |
using System; | |
using System.Threading.Tasks; | |
namespace BlogCore.PostContext | |
{ | |
[Produces("application/json")] | |
[Route("public/api/blogs")] | |
public class PostApiPublicController : Controller | |
{ | |
private readonly IMediator _eventAggregator; | |
private readonly ListOutPostByBlogInteractor _listOutPostByBlogInteractor; | |
private readonly ListOutPostByBlogPresenter _listOutPostByBlogPresenter; | |
public PostApiPublicController( | |
IMediator eventAggregator, | |
ListOutPostByBlogInteractor listOutPostByBlogInteractor, | |
ListOutPostByBlogPresenter listOutPostByBlogPresenter) | |
{ | |
_eventAggregator = eventAggregator; | |
_listOutPostByBlogInteractor = listOutPostByBlogInteractor; | |
_listOutPostByBlogPresenter = listOutPostByBlogPresenter; | |
} | |
[HttpGet("{blogId:guid}/posts")] | |
public async Task<PaginatedItem<ListOutPostByBlogResponse>> GetForBlog(Guid blogId, [FromQuery] int page) | |
{ | |
var result = _listOutPostByBlogInteractor.Process(new ListOutPostByBlogRequest(blogId, page <= 0 ? 1 : page)); | |
return await _listOutPostByBlogPresenter.Transform(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment