public ActionResult createCourse(course model) { if(db.courses.Where(m => m.defineCourse == model.defineCourse).Count()>0) { ModelState.AddModelError("", "This course name, as you're creating, mut be unique"); return View(); } db.courses.Add(new course { defineCourse = model.defineCourse, headerTopic = (from top in db.topics where top.topicID == model.headerTopic.topicID select top).First() }); db.SaveChanges(); return View("getTopics"); }
public ActionResult editCourse(course model, string id) { course courseToEdit = (from co in db.courses where co.defineCourse == id select co).First(); courseToEdit.defineCourse = model.defineCourse; courseToEdit.headerTopic = (from top in db.topics where top.topicID == model.headerTopic.topicID select top).First(); db.SaveChanges(); return View("getTopics"); }
public ActionResult editCourse(string id) { course model = new course(); model.defineCourse = id; return View(model); }