public ActionResult radio_buttons(int? symposium_id) { if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated == true) { if (symposium_id != null) { Symposium symposium = db.Symposiums.Find(symposium_id); ViewBag.Symposium = symposium; ViewBag.Projects = symposium.Projects.ToList(); Project[] projects = symposium.Projects.Distinct().ToArray(); int array_length = projects.Count(); int[] course_ids = new int[array_length]; for (int i = 0; i < projects.Count(); i++) { course_ids[i] = projects[i].courseID; } Course[] found_courses = new Course[projects.Count()]; for (int i = 0; i < projects.Count(); i++) { found_courses[i] = db.Courses.Find(projects[i].courseID); } found_courses = found_courses.Distinct().ToArray(); ViewBag.Course_Count = found_courses.Count(); ViewBag.Courses = found_courses; } return View(); } else { return RedirectToAction("desktop_vote", "Projects"); } }
public ActionResult dropdown_for_courses(int? symposium_id) { if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated == true) { if (symposium_id == null) { var symposiums = db.Symposiums.ToList(); int i = 0; int count = 0; foreach (var item in symposiums) { count = count + item.Courses.Count(); } Course[] found_courses = new Course[db.Courses.Count()]; found_courses[0] = db.Courses.First(); int ix = 0; var all_courses = db.Courses.ToList(); List<Course> list = new List<Course>(); foreach (var item in all_courses) { if (list.Where(x => x.courseNumber == item.courseNumber).FirstOrDefault() == null) { list.Add(item); ix++; } } ViewBag.CourseNames = db.Courses.Select(x=> x.courseName).ToArray(); ViewBag.CourseNumbers = db.Courses.Select(x => x.courseName); ViewBag.Courses = list; ViewBag.Course_Count = db.Courses.ToList().Count(); } else { Symposium found_symposium = db.Symposiums.Find(symposium_id); Project[] projects = found_symposium.Projects.Distinct().ToArray(); int array_length = projects.Count(); int[] course_ids = new int[array_length]; for (int i = 0; i < projects.Count(); i++) { course_ids[i] = projects[i].courseID; } Course[] found_courses = new Course[projects.Count()]; for (int i = 0; i < projects.Count(); i++) { found_courses[i] = db.Courses.Find(projects[i].courseID); } found_courses = found_courses.Distinct().ToArray(); ViewBag.Course_Count = found_courses.Count(); ViewBag.Courses = found_courses; } return View(); } else { return RedirectToAction("desktop_vote", "Projects"); } }