public async Task <IActionResult> Add([FromBody] HistoricoAddModel model) { try { return(new OkObjectResult(await _historicoService.Add(model))); } catch (Exception ex) { return(new OkObjectResult( new ResponseHistoricoAddModel { Historico = null, Message = ex.Message, Success = false } )); } }
public async Task <ResponseHistoricoAddModel> Add(HistoricoAddModel model) { // TODO: Validation: (CPF e Id não podem ser repetidos) try { var historicoEntity = _mapper.Map <HistoricoEntity>(model); var historicoEntityDb = await _historicoRepository.Insert(historicoEntity); _uow.SaveChanges(); return(new ResponseHistoricoAddModel { Historico = _mapper.Map <HistoricoModel>((HistoricoEntity)historicoEntityDb.Entity), Message = "Historico Registrada com Sucesso", Success = true }); } catch (Exception ex) { return(new ResponseHistoricoAddModel { Historico = null, Message = ex.Message, Success = false }); } }