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