public ActionResult Details(int id) { CourseWrapper model = new CourseWrapper(); model.ListOfCourses = (db.Courses.OrderByDescending(c => c.DateCreated).ToList()); model.SelectedCourse = db.Courses.Where(c => c.Id == id).ToList()[0]; model.Entries = (db.CourseEntries.Where(x => x.CourseId == model.SelectedCourse.Id).OrderByDescending(c => c.DateCreated).ToList()); return View("Index", model); }
public ActionResult Index() { CourseWrapper model = new CourseWrapper(); model.ListOfCourses = (db.Courses.OrderByDescending(c => c.DateCreated).ToList()); if (model.ListOfCourses.Count > 0 ) { model.SelectedCourse = model.ListOfCourses[0]; model.Entries = (db.CourseEntries.Where(x => x.CourseId == model.SelectedCourse.Id).ToList()); } else { model.SelectedCourse = new Course(); model.Entries = new List<CourseEntry>(); } return View(model); }