Пример #1
0
        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);
        }
Пример #2
0
        public BaseFilterModel GetDefaultFilterModel()
        {
            var filterModel = new BaseFilterModel();

            filterModel.EnglishLevel = EnglishLevelUtils.GetAllEnglishLevels();
            filterModel.GrammarPart  = ExistedGrammarParts;

            return(filterModel);
        }