public ActionResult Create(School school) { if (ModelState.IsValid) { db.Schools.AddObject(school); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CountryId = new SelectList(db.Countries, "CountryId", "CountryName", school.CountryId); ViewBag.InstructorId = new SelectList(db.Students, "StudentId", "WKSAId", school.InstructorId); return View(school); }
/// <summary> /// Deprecated Method for adding a new object to the Schools EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSchools(School school) { base.AddObject("Schools", school); }
public ActionResult Edit(School school) { if (ModelState.IsValid) { db.Schools.Attach(school); db.ObjectStateManager.ChangeObjectState(school, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CountryId = new SelectList(db.Countries, "CountryId", "CountryName", school.CountryId); ViewBag.InstructorId = new SelectList(db.Students, "StudentId", "WKSAId", school.InstructorId); return View(school); }
/// <summary> /// Create a new School object. /// </summary> /// <param name="schoolId">Initial value of the SchoolId property.</param> /// <param name="schoolCode">Initial value of the SchoolCode property.</param> /// <param name="schoolName">Initial value of the SchoolName property.</param> /// <param name="countryId">Initial value of the CountryId property.</param> /// <param name="instructorName">Initial value of the InstructorName property.</param> public static School CreateSchool(global::System.Int32 schoolId, global::System.String schoolCode, global::System.String schoolName, global::System.Int32 countryId, global::System.String instructorName) { School school = new School(); school.SchoolId = schoolId; school.SchoolCode = schoolCode; school.SchoolName = schoolName; school.CountryId = countryId; school.InstructorName = instructorName; return school; }