public ActionResult DetailedSchedule(string studentId) { if (studentId == null) { return(RedirectToAction("Index", "Home")); } User student = usersRepo.UserById(studentId); if (student == null) { return(RedirectToAction("Index", "Home")); } WeekDays weekDay = schedRepo.GetCurrentDay(); ViewBag.StudentsName = student.ToString(); return(View(schedRepo.StudentSchedules(studentId) .Where(s => s.WeekDay == weekDay) .Select(s => new PartialScheduleVM { SubjectName = s.Course.Subject.Name, TeacherName = s.Course.Teacher.ToString(), Classroom = s.Classroom.Name + " (" + s.Classroom.Location + ")", WeekDay = weekDay.ToString() + "s", BeginningTime = s.BeginningTime, EndingTime = s.EndingTime }) .ToList())); }
public List <LastLessonVM> GetLastLesson(string studentName) { if (studentName == null) { return(new List <LastLessonVM>()); } IEnumerable <User> students = usersRepo.UsersByUsersname(studentName); List <LastLessonVM> viewModel = new List <LastLessonVM>(); WeekDays weekDay = schedRepo.GetCurrentDay(); foreach (User student in students) { Schedule lastLesson = schedRepo.LastLesson(student.Id, weekDay); if (lastLesson != null) { viewModel.Add(new LastLessonVM { Student = new PartialUserVM { Id = student.Id, FirstName = student.FirstName, LastName = student.LastName }, SubjectName = lastLesson.Course.Subject.Name, ClassroomName = lastLesson.Classroom.Name, ClassroomLocation = lastLesson.Classroom.Location, EndingTime = lastLesson.EndingTime }); } } return(viewModel); }