public IActionResult UpdateWord(int id, [FromBody] WordForUpdateDto wordForUpdateDto)
        {
            try
            {
                if (wordForUpdateDto == null)
                {
                    return(BadRequest());
                }

                if (!ModelState.IsValid)
                {
                    return(new UnprocessableEntityObjectResult(ModelState));
                }

                var word = _unitOfWork.Words.UpdateWord(id, wordForUpdateDto);

                if (!_unitOfWork.Save())
                {
                    throw new Exception("Failed to save word.");
                }

                return(NoContent());
            }
            catch (DuplicateNameException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
        public Word UpdateWord(int id, WordForUpdateDto dto)
        {
            if (_query.Any(x => x.Name.Equals(dto.Name) && !x.Id.Equals(id)))
            {
                throw new DuplicateNameException(dto.Name);
            }

            var word = Find(id);

            if (word == null)
            {
                throw new NotFoundException();
            }

            return(_mapper.Map(dto, word));
        }