public async Task <ActionResult <Vocabulary> > UpdateVocabulary(int vocabularyId, [FromBody] SaveVocabularyDto saveVocabularyDto)
        {
            var validator        = new SaveVocabularyDtoValidator();
            var validationResult = await validator.ValidateAsync(saveVocabularyDto);

            if (!validationResult.IsValid)
            {
                foreach (ValidationFailure failure in validationResult.Errors)
                {
                    return(BadRequest(failure.ErrorMessage));
                }
            }

            var vocabularyToUpdate = await _vocabularyService.GetVocabularyById(vocabularyId);

            if (vocabularyToUpdate == null)
            {
                return(NotFound());
            }

            var vocabulary = _mapper.Map <SaveVocabularyDto, Vocabulary>(saveVocabularyDto);
            await _vocabularyService.UpdateVocabulary(vocabularyToUpdate, vocabulary);

            var updatedVocabulary = await _vocabularyService.GetVocabularyById(vocabularyId);

            var updatedVocabularyDto = _mapper.Map <Vocabulary, VocabularyDto>(updatedVocabulary);

            return(Ok(updatedVocabularyDto));
        }
        public async Task <ActionResult <Vocabulary> > CreateVocabulary([FromBody] SaveVocabularyDto saveVocabularyDto)
        {
            var validator        = new SaveVocabularyDtoValidator();
            var validationResult = await validator.ValidateAsync(saveVocabularyDto);

            if (!validationResult.IsValid)
            {
                foreach (ValidationFailure failure in validationResult.Errors)
                {
                    return(BadRequest(failure.ErrorMessage));
                }
            }

            var vocabularyToCreate = _mapper.Map <SaveVocabularyDto, Vocabulary>(saveVocabularyDto);
            var newVocabulary      = await _vocabularyService.CreateVocabulary(vocabularyToCreate);

            var vocabularyDto = _mapper.Map <Vocabulary, VocabularyDto>(newVocabulary);

            return(Ok(vocabularyDto));
        }