public async Task <IActionResult> AddDictionary([FromBody] DictionaryCreateDto dictionaryDto)
        {
            if (dictionaryDto == null)
            {
                return(NotFound());
            }
            var dictionary = _mapper.Map <Dictionary>(dictionaryDto);
            await _repository.Dictionary.Create(dictionary);

            await _repository.Save();

            return(CreatedAtRoute(nameof(GetDictionaryById), new { dictionary.Id }, dictionary));
        }
예제 #2
0
        public async Task <IActionResult> AddDictionary([FromBody] DictionaryCreateDto dictionaryDto)
        {
            if (dictionaryDto == null)
            {
                return(NotFound());
            }
            if (!ModelState.IsValid)
            {
                _logger.LogError("Invalid model state for the WordCreateDto object");
                return(UnprocessableEntity(ModelState));
            }
            var dictionary = _mapper.Map <Dictionary>(dictionaryDto);
            await _service.CreateDictionary(dictionary);

            await _service.Save();

            return(CreatedAtRoute(nameof(GetDictionaryById), new { dictionary.Id }, dictionary));
        }