示例#1
0
 public void FilterStudentYear()
 {
     // If there's a valid selection aka if something other than "None" or NULL is selected then filter
     if (IsClearable())
     {
         StudentInformationCollection.Clear();
         var studentInfoStudentYear = AllStudentInformation.Where(i => i.SstudentYear == SelectedStudentYear.StudentYearDescription).ToList();
         NumberOfStudents = studentInfoStudentYear.Count();
         foreach (var info in studentInfoStudentYear)
         {
             StudentInformationCollection.Add(info);
         }
     }
 }
示例#2
0
 public void FilterOnLastName()
 {
     // If there's a valid selection aka if something other than "None" or NULL is selected then filter
     if (IsClearable())
     {
         StudentInformationCollection.Clear();
         var studentLN = AllStudentInformation.Where(i => i.SLastName == SelectedLastName.StudentLastName).ToList();
         NumberOfStudents = studentLN.Count();
         foreach (var info in studentLN)
         {
             StudentInformationCollection.Add(info);
         }
     }
 }
示例#3
0
        /// <summary>
        /// Displays all the students with no filters applied
        /// Stores all student information in AllStudentInformation list
        /// this list is then used for the rest of the view lifetime.
        /// Only retrieve info from database once if AllStudentInformation is empty
        /// </summary>
        public void PopulateResultView_NoFilters()
        {
            try
            {
                using (var context = new SchoolU_DBEntities())
                {
                    if (!AllStudentInformation.Any())
                    {
                        var allStudentRelatedInformation = (from s in context.Students
                                                            join sy in context.StudentYears on s.StudentYearId equals sy.StudentYearId
                                                            join sm in context.StudentMajors on s.StudentId equals sm.StudentId
                                                            join m in context.Majors on sm.MajorId equals m.MajorId
                                                            select new
                        {
                            s.StudentFirstName,
                            s.StudentLastName,
                            m.MajorDescription,
                            sy.StudentYearDescription
                        }).ToList();

                        NumberOfStudents = allStudentRelatedInformation.Count();

                        foreach (var item in allStudentRelatedInformation)
                        {
                            AllStudentInformation.Add(new StudentInformationModel
                            {
                                SFirstName   = item.StudentFirstName,
                                SLastName    = item.StudentLastName,
                                SMajor       = item.MajorDescription,
                                SstudentYear = item.StudentYearDescription
                            });
                        }
                        foreach (var item in AllStudentInformation)
                        {
                            StudentInformationCollection.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                return;
            }
        }