示例#1
0
        async void FindReplacementsAsync()
        {
            Replacements.Clear();
            replacementsModel.SetReplaced(DisplayedCourses.ElementAt(SelectedCourseIndex).Model);

            List <ReplacementModel> result = null;

            result = await Task.Run(() => {
                try
                {
                    return(replacementsModel.GetReplacementsFromData());
                }
                catch (DataServiceException e)
                {
                    Debug.WriteLine(e.Message);
                    ShowAlert();
                }
                return(result);
            });

            if (result != null)
            {
                foreach (ReplacementModel rm in result)
                {
                    Replacements.Add(new ReplacementViewModel(rm));
                }
            }
        }
示例#2
0
        void FilterCourses()
        {
            RefreshLocalCourses();
            List <CourseViewModel> lcvm = courseViewModels;

            lcvm = lcvm.FindAll(cvm => cvm.Language.Equals(_searchLanguage));

            lcvm = lcvm.FindAll(cvm => cvm.StudyType.Equals(_searchStudyType));

            if (_searchCourseType != default)
            {
                lcvm = lcvm.FindAll(cvm => cvm.Type.Equals(_searchCourseType));
            }

            if (_searchName != null && _searchName != string.Empty)
            {
                lcvm = lcvm.FindAll(cvm => cvm.Name.ToUpper().Contains(_searchName.ToUpper()));
            }

            if (_searchFaculty != null && _searchFaculty != string.Empty)
            {
                lcvm = lcvm.FindAll(cvm => cvm.FacultySymbol.ToUpper().Contains(_searchFaculty.ToUpper()));
            }
            if (_searchCode != null && _searchCode != string.Empty)
            {
                lcvm = lcvm.FindAll(cvm => cvm.Code.ToUpper().Contains(_searchCode.ToUpper()));
            }
            if (_searchFieldOfStudy != null && _searchFieldOfStudy != string.Empty)
            {
                lcvm = lcvm.FindAll(cvm => cvm.FieldOfStudy.ToUpper().Contains(_searchFieldOfStudy.ToUpper()));
            }

            if (ListChanged(DisplayedCourses.ToList(), lcvm))
            {
                DisplayedCourses.Clear();
                foreach (CourseViewModel cvm in lcvm)
                {
                    DisplayedCourses.Add(cvm);
                }
            }

            if (_searchCode.Equals(string.Empty) &&
                _searchFaculty.Equals(string.Empty) &&
                _searchFieldOfStudy.Equals(string.Empty) &&
                _searchName.Equals(string.Empty))
            {
                DisplayedCourses.Clear();
            }
        }