public ActionResult Student() { UserCourseGetReponse ucgr = _courseCom.GetCourseForUser(User.Identity.Name); StudentDashboardModel sdm = new StudentDashboardModel(); if (ucgr != null) { sdm.AllCourseDropDown = new List <string>(); sdm.selectedCourse = null; sdm.selectedRegisteredCourse = null; sdm.RegisteredCourseDropDown = new List <string>(); if (ucgr.RegisteredCourses != null) { foreach (var crs in ucgr.RegisteredCourses) { sdm.RegisteredCourseDropDown.Add(crs.CourseCode + " :: " + crs.CourseNane + " (" + crs.Term + ")"); } } if (ucgr.EligibleToRegisterCourses != null) { foreach (var crs in ucgr.EligibleToRegisterCourses) { if (ucgr.RegisteredCourses != null && !ucgr.RegisteredCourses.Any(x => x.CourseCode == crs.CourseCode && x.Term == crs.Term)) { sdm.AllCourseDropDown.Add(crs.CourseCode + " :: " + crs.CourseNane + " (" + crs.Term + ")"); } } } } return(View(sdm)); }
public ActionResult Register(StudentDashboardModel model) { if (ModelState.IsValid) { string[] stringSeparators = new string[] { " :: " }; if (!string.IsNullOrWhiteSpace(model.selectedCourse)) { string courseCode = model.selectedCourse.Split(stringSeparators, StringSplitOptions.None).FirstOrDefault(); return(RedirectToAction("JoinACourse", "Course", routeValues: new { courseCode = courseCode })); } } ModelState.AddModelError("", "Oops! Something wrong happened! Please try again."); return(View(model)); }
public ActionResult Dashboard() { // Create the dashboard for a student with their subjects, presences and appointments. var student = Student; var model = new StudentDashboardModel { Subjects = _subjectRepository.GetAll() .Where(s => s.StartDate.Date == DateTime.Now.Date) .ToList(), Presences = _presenceRepository.GetByStudent(student.Id), Appointments = _appointmentRepository.GetAppointmentsByStudent(student.Id, GetFirstSaturday(), DateTime.Now) }; return(View(model)); }
public IActionResult Dashboard(int studentId) { ActionResult result = null; int _role = 0; if (IsAuthenticated) { _role = CurrentUser.RoleId; if (_role == 2) { List <Course> courses = (List <Course>)_coursedb.GetStudentCourses(studentId); StudentDashboardViewModel courseList = new StudentDashboardViewModel() { DashStudentId = CurrentUser.Id, DashStudentName = CurrentUser.FirstName }; foreach (Course entry in courses) { StudentDashboardModel viewCourse = new StudentDashboardModel(_coursedb) { CourseTitle = entry.Name, CourseId = entry.Id, Image = entry.Image, StudentId = CurrentUser.Id }; courseList.DashCourseList.Add(viewCourse); } result = View(courseList); } else { result = RedirectToAction("Dashboard", "Teacher"); } } else { result = RedirectToAction("Login", "User"); } return(result); }