public async Task <IActionResult> Put(PostDTO item) { if (!ModelState.IsValid) { return(BadRequest(new ApiBadRequestResponse(ModelState))); } var command = new PutPostCommand(item); var handler = _factory.Build(command); var response = await handler.Execute(); if (response.Success) { item.PostId = response.ID; return(Ok(item)); } else { return(BadRequest(new ApiResponse(500))); } }
public ICommandHandler <PutPostCommand, CommandResponse> Build(PutPostCommand command) { return(new PutPostCommandHandler(_serviceProvider.GetService <IPostsRepository>(), command)); }