public ActionResult Create(Picture picture) { if (ModelState.IsValid) { db.Pictures.AddObject(picture); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CatID = new SelectList(db.Categories, "CatID", "CatName", picture.CatID); return View(picture); }
/// <summary> /// Create a new Picture object. /// </summary> /// <param name="picID">Initial value of the PicID property.</param> /// <param name="picUrl">Initial value of the PicUrl property.</param> /// <param name="picAltText">Initial value of the PicAltText property.</param> public static Picture CreatePicture(global::System.Int64 picID, global::System.String picUrl, global::System.String picAltText) { Picture picture = new Picture(); picture.PicID = picID; picture.PicUrl = picUrl; picture.PicAltText = picAltText; return picture; }
/// <summary> /// Deprecated Method for adding a new object to the Pictures EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPictures(Picture picture) { base.AddObject("Pictures", picture); }
public ActionResult Edit(Picture picture) { if (ModelState.IsValid) { db.Pictures.Attach(picture); db.ObjectStateManager.ChangeObjectState(picture, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CatID = new SelectList(db.Categories, "CatID", "CatName", picture.CatID); return View(picture); }