public async Task <IActionResult> Post([FromBody] GrupoFormViewModel model) { var entity = _mapper.Map <Grupo>(model); var result = await _grupoService.Cadastrar(entity); if (result.IsValid) { return(Ok(_mapper.Map <GrupoViewModel>(result.Entity))); } return(BadRequest(result.Result)); }
public async Task <IActionResult> Put(Guid id, [FromBody] GrupoFormViewModel model) { if (!await _grupoService.Existe(id)) { return(RegistroNaoEncontrado(id)); } var result = await _grupoService.Editar(id, _mapper.Map <Grupo>(model)); if (result.IsValid) { return(Ok(_mapper.Map <GrupoViewModel>(result.Entity))); } return(BadRequest(result.Result)); }