public IActionResult Atualizar(int id, CadastroEspacoAvulsoEmDiscoDTO model) { try { string tela = this.ControllerContext.RouteData.Values["action"].ToString(); this._auditoria.cadastrar(tela, this.User.Identity.Name, model); var l = this._service.getEspacoAvulsoEmDiscoById(id); if (l == null) { return(NotFound("Espaço Avulso em Disco não encontrada!")); } var espacoAvulsoEmDisco = new EspacoAvulsoEmDisco(); _mapper.Map(model, espacoAvulsoEmDisco); this._service.Autalizar(espacoAvulsoEmDisco); return(Ok(espacoAvulsoEmDisco)); } catch (Exception ex) { return(BadRequest(new { message = ex.Message })); } }
public IActionResult Cadastrar(CadastroEspacoAvulsoEmDiscoDTO model) { try { string tela = this.ControllerContext.RouteData.Values["action"].ToString(); this._auditoria.cadastrar(tela, this.User.Identity.Name, model); var espacoAvulsoEmDisco = _mapper.Map <EspacoAvulsoEmDisco>(model); var sucesso = this._service.Cadastrar(espacoAvulsoEmDisco); if (sucesso) { return(Created($"/api/espacoAvulsoEmDisco/buscarEspacoAvulsoEmDiscoPorId/{espacoAvulsoEmDisco.Id}", espacoAvulsoEmDisco)); } } catch (Exception ex) { return(BadRequest(new { message = ex.Message })); } return(BadRequest()); }