public ActionResult DeleteConfirmed(int id) { CourseTopic coursetopic = db.CourseTopics.Find(id); db.CourseTopics.Remove(coursetopic); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,CourseId,TopicId")] CourseTopic coursetopic) { if (ModelState.IsValid) { db.Entry(coursetopic).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseId = new SelectList(db.Courses, "Id", "Name", coursetopic.CourseId); ViewBag.TopicId = new SelectList(db.Topics, "Id", "Name", coursetopic.TopicId); return(View(coursetopic)); }
// GET: /CourseTopic/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CourseTopic coursetopic = db.CourseTopics.Find(id); if (coursetopic == null) { return(HttpNotFound()); } return(View(coursetopic)); }
// GET: /CourseTopic/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CourseTopic coursetopic = db.CourseTopics.Find(id); if (coursetopic == null) { return(HttpNotFound()); } ViewBag.CourseId = new SelectList(db.Courses, "Id", "Name", coursetopic.CourseId); ViewBag.TopicId = new SelectList(db.Topics, "Id", "Name", coursetopic.TopicId); return(View(coursetopic)); }
public void SaveTopic(CourseTopic topic) { if (topic.ID == Guid.Empty) { _context.CourseTopics.Add(topic); } else { CourseTopic dbEntry = _context.CourseTopics.Find(topic.ID); if (dbEntry != null) { dbEntry.Name = topic.Name; dbEntry.OrderNumber = topic.OrderNumber; } } _context.SaveChanges(); }
public void Insert(CourseTopic obj) { service.Post <CourseTopicValidator>(obj); }
public void Update(CourseTopic obj) { service.Put <CourseTopicValidator>(obj); }
public ActionResult CreateNewTopic(int?idCourse, int?idClass, int?idTopic, [Bind(Include = "Id,Name,CourseId")] Topic topic, [Bind(Include = "Id,CourseId,TopicId")] CourseTopic coursetopic) { var teacher = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); ViewData["Teacher"] = teacher; if (ModelState.IsValid) { db.Topics.Add(topic); db.SaveChanges(); db.CourseTopics.Add(coursetopic); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseId = idCourse; ViewBag.TopicId = idTopic; return(View(topic)); }