コード例 #1
0
ファイル: CourseController.cs プロジェクト: EndOfLinee/LMS
 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);
 }
コード例 #2
0
ファイル: CourseController.cs プロジェクト: EndOfLinee/LMS
 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);
 }