public IActionResult Put(EmpresaEdicaoModel model) { try { var empresaDTO = empresaApplicationService.Update(model); return(StatusCode(200, new { Message = "Empresa atualizada com sucesso.", Empresa = empresaDTO })); } catch (Exception e) { return(StatusCode(500, new { e.Message }));; } }
public EmpresaDTO Update(EmpresaEdicaoModel model) { var empresaEntity = empresaDomainService.GetById(model.Id); if (empresaEntity == null) { throw new Exception("Empresa não encontrada."); } empresaEntity.NomeFantasia = model.NomeFantasia; empresaDomainService.Update(empresaEntity); return(new EmpresaDTO { Id = empresaEntity.Id, RazaoSocial = empresaEntity.RazaoSocial, NomeFantasia = empresaEntity.NomeFantasia, Cnpj = empresaEntity.Cnpj }); }