public ObjectResult Post([FromBody] EnvironmentSaveDTO environmentDTO) { try { if (!_validator.IsValidSaveDTO(environmentDTO)) { return(BadRequest(_validator.ValidationResult)); } var environment = _mapper.Map <Domain.Models.Environment>(environmentDTO); _repository.Create(environment); return(Ok(_mapper.Map <EnvironmentViewDTO>(environment))); } catch (Exception ex) { return(StatusCode(500, $"Ocorreu um erro inesperado: {ex.Message}")); } }
public bool IsValidSaveDTO(EnvironmentSaveDTO dto) { Environment environment = _mapper.Map <Environment>(dto); return(IsValid(environment)); }