Esempio n. 1
0
        // Method to Check Homework Submission in the database.
        public static void CheckSubmission()
        {
            StudentRepository    studentrepo    = new StudentRepository();
            FacultyRepository    facultyrepo    = new FacultyRepository();
            AssignmentRepository assignmentrepo = new AssignmentRepository();
            HomeworkRepository   homeworkrepo   = new HomeworkRepository();
            HomeController       hc             = new HomeController();

            List <Assignment> assignments = assignmentrepo.Assignment_Read();
            List <Student>    students    = studentrepo.Student_Read();
            List <Faculty>    faculties   = facultyrepo.Faculty_Read();
            List <Homework>   homeworks   = homeworkrepo.Homework_Read();

            for (int i = 0; i < students.Count; i++)
            {
                for (int j = 0; j < assignments.Count; j++)
                {
                    DateTime t1 = assignments[j].createdOn.ToLocalTime();
                    TimeSpan t2 = DateTime.Now.Subtract(t1);
                    //if (t2.TotalHours <= 24)
                    //{
                    //    for(int k = 0; k < homeworks.Count; k++)
                    //    {
                    //        if (students[i].StudentId == homeworks[k].StudentId && homeworks[k].FacultyId == assignments[j].FacultyId)
                    //        {
                    //            students.Remove(students[i]);
                    //            break;
                    //        }
                    //    }
                    //    break;
                    //}
                    //else
                    //{
                    for (int k = 0; k < homeworks.Count; k++)
                    {
                        DateTime t3 = homeworks[k].createdOn.ToLocalTime();
                        TimeSpan t4 = t1.Subtract(t3);
                        if (students[i].StudentId == homeworks[k].StudentId && homeworks[k].FacultyId == assignments[j].FacultyId && t4.TotalHours < 24)
                        {
                            students.Remove(students[i]);
                            break;
                        }
                    }
                    //}
                }
            }
            for (int i = 0; i < students.Count; i++)
            {
                for (int j = 0; j < assignments.Count; j++)
                {
                    DateTime t1 = assignments[j].createdOn.ToLocalTime();
                    TimeSpan t2 = DateTime.Now.Subtract(t1);
                    if (t2.TotalHours > 12 && t2.TotalHours < 23)
                    {
                        hc.Student_Notification(students[i].StudentId, true);
                    }
                    else if (t2.TotalHours >= 24 && t2.TotalHours < 30)
                    {
                        hc.Student_Notification(students[i].StudentId, false);
                        for (int k = 0; k < faculties.Count; k++)
                        {
                            if (assignments[k].FacultyId == faculties[k].FacultyId)
                            {
                                hc.Faculty_Notification(faculties[k].FacultyId, students[i].StudentId, false);
                            }
                        }
                    }
                }
            }
            return;
        }
Esempio n. 2
0
        // Method to Read the total number of Faculties from the database.
        public ActionResult Faculty_Read()
        {
            List <Faculty> data = facultyrepo.Faculty_Read();

            return(View("Faculty_Read", data));
        }