public ActionResult Index() { if (!loggedIn()) { return(RedirectToAction("Index", "Login")); } ViewData["title"] = "Enrollment Dashboard"; //If the user and role aren't null if (Session["role"] != null) { ViewData["Role"] = Session["role"]; currentUser = (User)Session["user"]; //If the user is a student if (checkPermission("student")) { ViewData["SectionsTitle"] = "Enrolled Sections"; Student student = proxy.getStudent(currentUser.ID); currentSections = proxy.getStudentSections(student); Section[] currentWaitlists = proxy.getStudentWaitlists(student); List <SectionDisplay> waitlists = new List <SectionDisplay>(); for (int i = 0; i < currentWaitlists.Length; i++) { waitlists.Add(getSectionData(currentWaitlists[i])); } ViewData["StudentWaitlists"] = waitlists.ToArray(); } //If the user is an instructor else if (checkPermission("professor")) { ViewData["SectionsTitle"] = "Instructor Sections"; currentSections = proxy.getInstructorSectionsByID(currentUser.ID); } //If the user is an admin else if (checkPermission("admin")) { return(RedirectToAction("Index", "Admin")); } } for (int i = 0; i < currentSections.Length; i++) { sectionsData.Add(getSectionData(currentSections[i])); } return(View(sectionsData.ToArray())); }