コード例 #1
0
        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}"));
            }
        }
コード例 #2
0
        public bool IsValidSaveDTO(EnvironmentSaveDTO dto)
        {
            Environment environment = _mapper.Map <Environment>(dto);

            return(IsValid(environment));
        }