示例#1
0
        public SearchFilter ApplyFilter()
        {
            if (CityName == "" && FacultyName == "" && ProfessorName == "" && MinReview == 0 && MaxReview == Int16.MaxValue)
            {
                return(this);
            }

            if (CityName != "")
            {
                Cities    = Cities.Where(city => city.Name.ToLower().Contains(CityName.ToLower()));
                Faculties = Cities.SelectMany(c => c.Universities).SelectMany(u => u.Faculties);
                Subjects  = Subjects.Where(s => Faculties.Contains(s.Faculty));
                var professors = Subjects.SelectMany(s => s.Professors).Select(s => s.Professor);
                Professors = Professors.Where(p => professors.Contains(p));
            }
            if (FacultyName != "")
            {
                Faculties = Faculties.Where(faculty => faculty.Name.ToLower().Contains(FacultyName.ToLower()));
                Subjects  = Subjects.Where(s => Faculties.Contains(s.Faculty));
                var professors = Subjects.SelectMany(s => s.Professors).Select(s => s.Professor);
                Professors = Professors.Where(p => professors.Contains(p));
            }
            if (ProfessorName != "")
            {
                Professors = Professors.Where(professor => professor.FullName.ToLower().Contains(ProfessorName.ToLower()));
                var subjects = Professors.SelectMany(p => p.Subjects).Select(p => p.Subject);
                Subjects = Subjects.Where(s => subjects.Contains(s));
            }
            if (MinReview.HasValue)
            {
                Professors = Professors.Where(professor => professor.Reviews.Count >= MinReview);
                Subjects   = Subjects.Where(subject => subject.Reviews.Count >= MinReview);
            }
            if (MaxReview.HasValue)
            {
                Professors = Professors.Where(professor => professor.Reviews.Count <= MaxReview);
                Subjects   = Subjects.Where(subject => subject.Reviews.Count <= MaxReview);
            }
            return(this);
        }
示例#2
0
        public void Query()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("sWhere", string.Format(
                               "{0} \"FacultyId\":\"{1}\",\"HexCode\":\"{2}\", \"CardNum\":\"{3}\",\"PersonId\":\"{4}\",\"Sex\":\"{5}\",\"Career\":\"{6}\",\"Email\":\"{7}\",\"Phone\":\"{8}\",\"CardType\":\"{9}\",\"Name\":\"{10}\"{11}"
                               , "{", FacultyId, HexCode, CardNum, PersonId, Sex, Career, Email, Phone, CardType, PersonName, "}"));
            int total = 0;

            try
            {
                Collection <IcCardModel> icCards =
                    restConnection.GetPageValues <IcCardModel>("api/IcCardInfoMaint/QueryIcCards"
                                                               , 1, 0, 1000000, parameters, ref total);
                if (null != icCards)
                {
                    Items.Clear();
                    foreach (var icCard in icCards)
                    {
                        //使icCard中的FacultyModel与Faculties集合中的对象为同一对象
                        //解决在下拉列表框中无法选中Id相同对象的问题
                        if (null != icCard.Faculty)
                        {
                            icCard.Faculty = Faculties.Where(p => p.Id == icCard.Faculty.Id).FirstOrDefault();
                        }
                        Items.Add(icCard);
                    }
                }
            }
            catch (Exception e)
            {
                RadWindow.Alert(new DialogParameters
                {
                    OkButtonContent = "确定",
                    Content         = e.Message,
                    Owner           = App.Current.MainWindow,
                    Header          = "错误"
                });
            }
        }
示例#3
0
        public void Query()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("sWhere", string.Format(
                               "{0} \"ClassAndGradeName\":\"{1}\",\"MajorName\":\"{2}\", \"EntranceDate\":\"{3}\",\"GraduationDate\":\"{4}\",\"FacultyId\":\"{5}\"{6}"
                               , "{", ClassAndGradeName, MajorName, EntranceDate, GraduationDate, FacultyId, "}"));
            int total = 0;

            try
            {
                Collection <ClassAndGradeModel> classesAndGrades =
                    restConnection.GetPageValues <ClassAndGradeModel>("api/ClassAndGrade/Query"
                                                                      , 1, 0, 1000000, parameters, ref total);
                if (null != classesAndGrades)
                {
                    Items.Clear();
                    foreach (var classAndGrade in classesAndGrades)
                    {
                        //使classAndGrade中的Faculty与Faculties集合中的对象为同一对象
                        //解决在下拉列表框中无法选中Id相同对象的问题
                        classAndGrade.Faculty = Faculties.Where(p => p.Id == classAndGrade.Faculty.Id).FirstOrDefault();
                        Items.Add(classAndGrade);
                    }
                }
            }
            catch (Exception e)
            {
                RadWindow.Alert(new DialogParameters
                {
                    OkButtonContent = "确定",
                    Content         = e.Message,
                    Owner           = App.Current.MainWindow,
                    Header          = "错误"
                });
            }
        }