public async Task <IActionResult> SaveComments(int id, [FromBody] SaveCommentCommand saveCommentCommand) { if (saveCommentCommand.Content.Length < 5) { return(BadRequest("Ocorreu um erro")); } await _mediator.Send(saveCommentCommand); return(NoContent());//CreatedAtAction(nameof(GetById), new { id = createCommentInputModel.Id }, createCommentInputModel); }
public ActionResult SaveComment(Comment comment, int mediaItemId, [FromServices] SaveCommentCommand saveCommentCmd) { var model = new SaveCommentModel(); model.mediaItemId = mediaItemId; model.comment = comment; model.User = User; if (!ModelState.IsValid) { var item = LoadMediaItem(mediaItemId); return(View("Picture", item)); } saveCommentCmd.Execute(model); return(RedirectToAction("Details", new { id = mediaItemId })); }
public async Task <ActionResult <string> > SaveComment([FromBody] SaveCommentCommand command) { var result = await Mediator.Send(command); return(new JsonResult(result)); }