public IActionResult CadastrarOccorrencia(OcorrenciaDomain ocorrencia) { try { return(Ok(OcorrenciaRepository.CadastrarOcorrencia(ocorrencia))); } catch (Exception ex) { return(BadRequest(new { mensagem = "Tente novamente mais tarde!" + ex.Message })); } }
public OcorrenciaDomain CadastrarOcorrencia(OcorrenciaDomain ocorrencia) { try { ctx.Ocorrencias.Add(ocorrencia); ctx.SaveChanges(); return(ocorrencia); } catch (Exception ex) { throw new Exception(ex.Message); } }