Пример #1
0
        public async Task <IActionResult> Post([FromBody] ValueForCreateDto valueForCreateDto)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }

                if (await _valueService.IsDuplicateAsync(valueForCreateDto.Name))
                {
                    return(BadRequest("Duplicate"));
                }

                await _valueService.AddAsync(valueForCreateDto);

                return(StatusCode(201));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode(500));
            }
        }