public ActionResult DeleteSubMenuItem(int id, string redirectUrl) { using (DataStorage context = new DataStorage()) { SiteContent content = (from c in context.SiteContent where c.Id == id select c).First(); context.DeleteObject(content); context.SaveChanges(); return Redirect(redirectUrl); } }
public ActionResult DeletePicture(int id, string contentUrl, string controllerName) { using (DataStorage context = new DataStorage()) { ImageContent image = (from i in context.ImageContent where i.Id == id select i).First(); string imageName = image.FileName; context.DeleteObject(image); context.SaveChanges(); string path = Server.MapPath("~/Content/Objects/" + imageName); if (!string.IsNullOrEmpty(imageName)) { //DeleteFileInTheThread(path); System.IO.File.Delete(path); } } return RedirectToAction("EditPicture", "Admin", new { contentUrl = contentUrl }); }