예제 #1
0
        public void SaveForExams(string word, string transcription, string[] translations, string[] allMeanings, Phrase[] phrases = null)
        {
            var alreadyExists = _repository.GetOrNull(word);

            if (alreadyExists == null)
            {
                _repository.CreateNew(word, string.Join(", ", translations), allMeanings, transcription, phrases);
            }
            else
            {
                var updatedTranslations = alreadyExists
                                          .Translation
                                          .Split(',', StringSplitOptions.RemoveEmptyEntries)
                                          .Select(s => s.Trim())
                                          .Union(translations)
                                          .ToArray();
                alreadyExists.Translation = string.Join(", ", updatedTranslations);
                alreadyExists.OnExamFailed();
                _repository.UpdateScoresAndTranslation(alreadyExists);
            }
        }