Пример #1
0
        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);
        }
Пример #2
0
 /// <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;
 }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Pictures EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPictures(Picture picture)
 {
     base.AddObject("Pictures", picture);
 }
Пример #4
0
 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);
 }