public ActionResult Edit(CourseGroup coursegroup) { if (ModelState.IsValid) { db.CourseGroups.Attach(coursegroup); db.ObjectStateManager.ChangeObjectState(coursegroup, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CourseId = new SelectList(db.Courses, "Id", "Name", coursegroup.CourseId); ViewBag.InstructorId = new SelectList(db.Instructors, "Id", "Fio", coursegroup.InstructorId); return View(coursegroup); }
public ActionResult Create(CourseGroup coursegroup) { if (ModelState.IsValid) { db.CourseGroups.AddObject(coursegroup); db.SaveChanges(); return RedirectToAction("Edit", new { id = coursegroup.Id }); } ViewBag.CourseId = new SelectList(db.Courses, "Id", "Name", coursegroup.CourseId); ViewBag.InstructorId = new SelectList(db.Instructors, "Id", "Fio", coursegroup.InstructorId); return View(coursegroup); }
/// <summary> /// Create a new CourseGroup object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="instructorId">Initial value of the InstructorId property.</param> /// <param name="name">Initial value of the Name property.</param> public static CourseGroup CreateCourseGroup(global::System.Int32 id, global::System.Int32 instructorId, global::System.String name) { CourseGroup courseGroup = new CourseGroup(); courseGroup.Id = id; courseGroup.InstructorId = instructorId; courseGroup.Name = name; return courseGroup; }
/// <summary> /// Deprecated Method for adding a new object to the CourseGroups EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCourseGroups(CourseGroup courseGroup) { base.AddObject("CourseGroups", courseGroup); }