public IActionResult Atualizar(int id, CadastroUsuarioAvulsoDTO model) { try { string tela = this.ControllerContext.RouteData.Values["action"].ToString(); this._auditoria.cadastrar(tela, this.User.Identity.Name, model); var l = this._service.getUsuarioAvulsoById(id); if (l == null) { return(NotFound("Usuário Avulso não encontrada!")); } var usuarioAvulso = new UsuarioAvulso(); _mapper.Map(model, usuarioAvulso); this._service.Autalizar(usuarioAvulso); return(Ok(usuarioAvulso)); } catch (Exception ex) { return(BadRequest(new { message = ex.Message })); } }
public IActionResult Cadastrar(CadastroUsuarioAvulsoDTO model) { try { string tela = this.ControllerContext.RouteData.Values["action"].ToString(); this._auditoria.cadastrar(tela, this.User.Identity.Name, model); var usuarioAvulso = _mapper.Map <UsuarioAvulso>(model); var sucesso = this._service.Cadastrar(usuarioAvulso); if (sucesso) { return(Created($"/api/usuarioAvulso/buscarUsuarioAvulsoPorId/{usuarioAvulso.Id}", usuarioAvulso)); } } catch (Exception ex) { return(BadRequest(new { message = ex.Message })); } return(BadRequest()); }