public async Task <ActionResult <AuthorModel> > AuthorCreate([FromBody] AuthorCreateCommand command) { await _mediator.DispatchAsync(command); var newAuthor = await _mediator.DispatchAsync(new GetAuthorByIdQuery(command.Id)); return(CreatedAtAction(nameof(AuthorGetById), new { authorId = newAuthor.Id }, newAuthor)); }
public async Task <IActionResult> Post([FromBody] AuthorCreateCommand command) { try { if (ModelState.IsValid) { return(Ok(await Mediator.Send(command))); } return(BadRequest()); } catch (Exception) { throw; } }