public ActionResult Delete(int id) { using (var context = new ContentStorage()) { var content = context.Content.Where(c => c.Id == id).First(); context.DeleteObject(content); context.SaveChanges(); } return RedirectToAction("Index", "Home", new {id="", area = "" }); }
public ActionResult DeleteGallery(int id) { using (var context = new ContentStorage()) { var gallery = context.Gallery.Include("GalleryItems").Where(g=>g.Id==id).First(); while (gallery.GalleryItems.Any()) { var galleryItem = gallery.GalleryItems.First(); IOHelper.DeleteFile("~/Content/Photos", galleryItem.ImageSource); IOHelper.DeleteFile("~/ImageCache/thumbnail", galleryItem.ImageSource); context.DeleteObject(galleryItem); } IOHelper.DeleteFile("~/Content/Photos", gallery.ImageSource); IOHelper.DeleteFile("~/ImageCache/thumbnail", gallery.ImageSource); context.DeleteObject(gallery); context.SaveChanges(); } return RedirectToAction("Index", "Gallery", new { Area = ""}); }
public ActionResult DeleteImage(int galleryId, int id) { using (var context = new ContentStorage()) { var galleryItem = context.Galleryitem.Where(gi => gi.Id == id).First(); var gallery = context.Gallery.Where(g => g.Id == galleryId).First(); IOHelper.DeleteFile("~/Content/Photos", galleryItem.ImageSource); IOHelper.DeleteFile("~/ImageCache/thumbnail", galleryItem.ImageSource); context.DeleteObject(galleryItem); context.SaveChanges(); return RedirectToAction("Details", "Gallery", new {Area = "", id = gallery.Name}); } }