public IActionResult SaveHours(string HoursTotal, int SubjectID, DateTime date) { Subject localSubject = subjectRepository.Subjects.FirstOrDefault(s => s.SubjectID == SubjectID); var students = new List <Student>(); var studentsSubjects = studentsSubjectsRepository.StudentsSubjects; var protocols = protocolRepository.Protocols; List <int> studentIDsInSubject = new List <int>(); studentIDsInSubject = studentsSubjectsRepository.StudentsBySubject(SubjectID); foreach (int id in studentIDsInSubject) { students.Add(studentRepository.FindStudentByID(id)); } TempData["HoursTotal"] = HoursTotal; foreach (Student student in students) { protocolRepository.UpdateProtocol(student.StudentID, HoursTotal, SubjectID, date); } return(View("RegisterAttendance", new ProtocolsListViewModel { Students = students, StudentsSubjects = studentsSubjects, Protocols = protocols, Date = date, Subject = localSubject })); }
public ViewResult EditSubject(int subjectID) { List <Student> studentsNot = new List <Student>(); List <Student> students = new List <Student>(); List <int> studentIDsInSubject = new List <int>(); Subject subject = repository.Subjects.FirstOrDefault(s => s.SubjectID == subjectID); if (subjectID == 0) { subject = new Subject(); } studentIDsInSubject = subStuRepository.StudentsBySubject(subjectID); foreach (int id in studentIDsInSubject) { students.Add(stuRepository.FindStudentByID(id)); } StudentsSubjectsViewModel ssv = new StudentsSubjectsViewModel(); ssv.Students = students; ssv.Subject = subject; ssv.StudentsNot = stuRepository.Students; studentsNot = ssv.StudentsNot.Except(students).ToList(); ssv.StudentsNot = studentsNot; return(View(ssv)); }
public IActionResult StudentStatistics(int subjectID) { Subject localSubject = SubRepository.Subjects.FirstOrDefault(s => s.SubjectID == subjectID); var studentsSubjects = SubStuRepository.StudentsSubjects; var protocols = ProtoRepository.Protocols; List <int> studentIDsInSubject = SubStuRepository.StudentsBySubject(subjectID); List <Student> students = new List <Student>(); foreach (int id in studentIDsInSubject) { students.Add(StuRepository.FindStudentByID(id)); } var attendanceList = new Dictionary <int, List <double> >(); foreach (Student student in students.OrderBy(o => o.Name)) { double TimerTotal = 0, TimerPresent = 0, TimerVirtual = 0, TimerPresentProcent = 0, TimerVirtualProcent = 0, TimerAbsentProcent = 0; var doubleList = new List <double>(); foreach (Protocol protocol in protocols.Where(p => p.SubjectID == localSubject.SubjectID && p.StudentID == student.StudentID)) { TimerTotal += protocol.HoursTotal; TimerPresent += protocol.HoursPresent; TimerVirtual += protocol.HoursVirtual; TimerPresentProcent = (TimerPresent / TimerTotal * 100); TimerVirtualProcent = (TimerVirtual / TimerTotal * 100); TimerAbsentProcent = ((TimerTotal - (TimerPresent + TimerVirtual)) / TimerTotal * 100); } doubleList.Add(TimerPresentProcent); doubleList.Add(TimerVirtualProcent); doubleList.Add(TimerAbsentProcent); attendanceList.Add(student.StudentID, doubleList); } return(View(new ProtocolsListViewModel { Subject = localSubject, Students = students, StudentsSubjects = studentsSubjects, Protocols = protocols, AttendanceList = attendanceList })); }