public async Task <IActionResult> Post([FromForm] AddPostRequest request,
                                               [FromServices] IAddPostUseCase useCase)
        {
            useCase.SetOutputPort(this);

            var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            await useCase.ExecuteAsync(userId,
                                       request.Title,
                                       request.Content,
                                       request.Image.OpenReadStream(),
                                       System.IO.Path.GetExtension(request.Image.FileName))
            .ConfigureAwait(false);

            return(_viewModel);
        }
Example #2
0
 public PostController(
     IMediator mediator,
     IPostService postService,
     IAddPostUseCase addPostUseCase,
     IDeletePostUseCase deletePostUseCase,
     PostApiPresenter <bool> deleteApiPresenter,
     PostApiPresenter <AddPostResponse> addApiPresenter
     )
 {
     _mediator           = mediator;
     _postService        = postService;
     _addPostUseCase     = addPostUseCase;
     _deletePostUseCase  = deletePostUseCase;
     _deleteApiPresenter = deleteApiPresenter;
     _addApiPresenter    = addApiPresenter;
 }
Example #3
0
 public PostController(
     IAddPostUseCase addPostUseCase,
     IRemovePostUseCase removePostUseCase,
     IUpdatePostUseCase updatePostUseCase,
     IGetAllPostUseCase getAllPostUseCase,
     IGetByIdPostUseCase getByIdPostUseCase,
     IGetByIdTopicUseCase getByIdTopicUseCase,
     IGetByIdUserUseCase getByIdUserUseCase)
 {
     this.addPostUseCase      = addPostUseCase;
     this.removePostUseCase   = removePostUseCase;
     this.updatePostUseCase   = updatePostUseCase;
     this.getAllPostUseCase   = getAllPostUseCase;
     this.getByIdPostUseCase  = getByIdPostUseCase;
     this.getByIdTopicUseCase = getByIdTopicUseCase;
     this.getByIdUserUseCase  = getByIdUserUseCase;
 }