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 UserCourseGetReponse GetCourseForUser(string emailID) { IEnumerable <Course> courses = _repCourse.Get(includes: "Questionnaire"); AspNetUsers user = _repUserProfile.Get(x => x.Email == emailID).FirstOrDefault(); IEnumerable <EntityModel.CourseUser> courseUser = _repCourseUserRole.Get(x => x.UserId == user.Id); UserCourseGetReponse ugr = new UserCourseGetReponse(); if (courseUser == null) { ugr.RegisteredCourses = null; } else { ugr.RegisteredCourses = new List <CourseForUser>(); foreach (var cu in courseUser) { var crs = courses.Where(x => x.CourseId == cu.CourseId).FirstOrDefault(); ugr.RegisteredCourses.Add(new CourseForUser() { CourseCode = crs.CourseCode, CourseNane = crs.CourseName, Term = crs.Term }); } } var eligible = courses.Where(x => x.Roaster.Contains(user.GTID)); if (eligible == null) { ugr.EligibleToRegisterCourses = null; } else { ugr.EligibleToRegisterCourses = new List <CourseForUser>(); foreach (var el in eligible) { ugr.EligibleToRegisterCourses.Add(new CourseForUser() { CourseCode = el.CourseCode, CourseNane = el.CourseName, Term = el.Term }); } } return(ugr); }