private BaseFilterModel GetFilterWithTheNearestEnglishLevel(int neededCount, EnglishLevel userEnglishLevel) { var grammarParts = new List <string>(); var englishLevels = new List <EnglishLevel>(); var totalCount = 0; englishLevels.Add(userEnglishLevel); grammarParts.AddRange(TasksInformationModels[userEnglishLevel].GrammarPartCount.Keys); totalCount += TasksInformationModels[userEnglishLevel].GrammarPartCount.Values.Sum(); var sortedEnglishLevelsByNearerToUser = EnglishLevelUtils.GetSortedEnglishLevelsByNearest(userEnglishLevel); foreach (var englishLevel in sortedEnglishLevelsByNearerToUser) { if (TasksInformationModels.TryGetValue(englishLevel, out var levelInformation)) { englishLevels.Add(englishLevel); grammarParts.AddRange(TasksInformationModels[englishLevel].GrammarPartCount.Keys); totalCount += TasksInformationModels[englishLevel].GrammarPartCount.Values.Sum(); if (totalCount >= neededCount) { break; } } } var baseFilterModel = new BaseFilterModel(); baseFilterModel.EnglishLevel = englishLevels; baseFilterModel.GrammarPart = grammarParts; return(baseFilterModel); }
public BaseFilterModel GetDefaultFilterModel() { var filterModel = new BaseFilterModel(); filterModel.EnglishLevel = EnglishLevelUtils.GetAllEnglishLevels(); filterModel.GrammarPart = ExistedGrammarParts; return(filterModel); }