public ActionResult Add(CourseForView viewCourse)
 {
     Course course = new Course(viewCourse);
     if (ModelState.IsValid)
     {
         _db.DbSet.Add(course);
         _db.SaveChanges();
     }
     return RedirectToAction("Add");
 }
Example #2
0
 public Course(CourseForView course)
 {
     Id            = course.Id;
     Name          = course.Name;
     SubjectIdJson = _js.Serialize(course.SubjectIdList);
 }
Example #3
0
 public Course(CourseForView course)
 {
     Id = course.Id;
     Name = course.Name;
     SubjectIdJson = _js.Serialize(course.SubjectIdList);
 }
 // Convert the list of courses to list of view courses
 //
 public List<CourseForView> GetAllCourseForView()
 {
     List<CourseForView> viewCoursList=new List<CourseForView>();
     List<Course> courseList = _db.DbSet.ToList();
     foreach (var course in courseList)
     {
         CourseForView viewCourse= new CourseForView(course);
         viewCoursList.Add(viewCourse);
     }
     return viewCoursList;
 }