public UserWordForLearning[] GetWordsForLearning(int userId, int count, int maxTranslationSize) { var wordsForLearning = _usersWordsService.GetWorstForUser(userId, count); foreach (var wordForLearning in wordsForLearning) { var translations = wordForLearning.GetTranslations().ToArray(); if (translations.Length <= maxTranslationSize) { continue; } var usedTranslations = translations.Randomize().Take(maxTranslationSize).ToArray(); wordForLearning.SetTranslation(usedTranslations); // Remove Phrases added as learning word for (int i = 0; i < wordForLearning.Phrases.Count; i++) { var phrase = wordForLearning.Phrases[i]; if (!usedTranslations.Contains(phrase.PhraseRuTranslate)) { wordForLearning.Phrases.RemoveAt(i); } } } return(wordsForLearning.ToArray()); }