public async Task <IActionResult> Post([FromBody] ArticleCatFormModel model, [FromServices] IMapper mapper) { var command = new CreateArticleCatCommand(); mapper.Map(model, command); var articleCatId = await Mediator.Send(command); return(Created(await GetArticleCatById(articleCatId))); }
public async Task <IActionResult> Put(int id, [FromBody] ArticleCatFormModel model, [FromServices] IMapper mapper) { var articleCat = await GetArticleCatById(id); if (articleCat == null) { return(NotFound()); } var updateCommand = new UpdateArticleCatCommand(articleCat); mapper.Map(model, updateCommand); await Mediator.Send(updateCommand); return(Updated(await GetArticleCatById(id))); }