public ActionResult Delete(int id, Picture image) { var db = new SedcDatabase(); var imageId = db.Pictures.FirstOrDefault(c => c.Id == id); db.Pictures.Remove(imageId); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Picture picture) { if (ModelState.IsValid) { var db = new SedcDatabase(); db.Pictures.Add(picture); db.SaveChanges(); return(RedirectToAction("Index")); } return(View("~/Views/Picture/CreateWithHelpers.cshtml", picture)); }
public ActionResult Edit(int id, Picture image) { var db = new SedcDatabase(); var img = db.Pictures.FirstOrDefault(x => x.Id == id); if (img == null) { return(RedirectToAction("Index")); } image.DisplayName = image.DisplayName; image.Id = image.Id; image.Url = image.Url; db.SaveChanges(); return(RedirectToAction("Index")); }