public ActionResult DeleteArticle(int id) { using (ContentStorage context = new ContentStorage()) { List<Article> articles = context.Article.Where(a => a.Id == id).ToList(); foreach (var item in articles) { context.DeleteObject(item); } context.SaveChanges(); } return RedirectToAction("Index", "News"); }
public ActionResult DeleteContentItem(int id) { using (var context = new ContentStorage()) { Content content = context.Content.Include("Children").Where(c => c.Id == id).FirstOrDefault(); string contentId = content.ContentId; if (content.Children.Count == 0) { context.DeleteObject(content); context.SaveChanges(); } return RedirectToAction("Index", "Content", new { id = "About" }); } }
public ActionResult DeleteGalleryItem(int id, string contentId) { using (var context = new ContentStorage()) { Gallery galleryItem = context.Gallery.Select(g => g).Where(g => g.Id == id).FirstOrDefault(); context.DeleteObject(galleryItem); context.SaveChanges(); return RedirectToAction("Index", "Content", new { id = contentId }); } }