public ActionResult Delete(int id) { using (var context = new SiteContainer()) { var article = context.Article.First(a => a.Id == id); context.DeleteObject(article); context.SaveChanges(); return RedirectToAction("Articles", "Home", new { area = "" }); } }
public ActionResult Delete(int id) { using (var context = new SiteContainer()) { var category = context.Category.Include("Products").First(c => c.Id == id); if (!category.Products.Any()) { context.DeleteObject(category); context.SaveChanges(); } } return RedirectToAction("Gallery", "Home", new { area = "" }); }
public ActionResult DeleteProductSize(int id) { using (var context = new SiteContainer()) { var productSize = context.ProductSize.Include("Product").First(ps => ps.Id == id); var productId = productSize.Product.Id; context.DeleteObject(productSize); context.SaveChanges(); return RedirectToAction("ProductDetails", "Home", new { area = "", id = productId }); } }
public ActionResult DeleteProductImage(int id) { using (var context = new SiteContainer()) { var productImage = context.ProductImage.Include("Product").First(pi => pi.Id == id); var productId = productImage.Product.Id; //if (productImage.Product.ImageSource == productImage.ImageSource) //{ //} ImageHelper.DeleteImage(productImage.ImageSource); context.DeleteObject(productImage); context.SaveChanges(); return RedirectToAction("ProductDetails", "Home", new { area = "", id = productId }); } }
public ActionResult Delete(int id, int? page) { using (var context = new SiteContainer()) { var product = context.Product.Include("Category").Include("ProductImages").First(p => p.Id == id); var categoryName = product.Category.Name; var specialCategory = product.Category.SpecialCategory; while (product.ProductImages.Any()) { var productImage = product.ProductImages.First(); ImageHelper.DeleteImage(productImage.ImageSource); context.DeleteObject(productImage); } ImageHelper.DeleteImage(product.ImageSource); context.DeleteObject(product); context.SaveChanges(); if (specialCategory) { return RedirectToAction("OurWorks", "Home", new { area = "" }); } return RedirectToAction("Gallery", "Home", new { area = "", id = categoryName }); } }
public ActionResult Delete(int id, int? page) { using (var context = new SiteContainer()) { var product = context.Product.First(p => p.Id == id); ImageHelper.DeleteImage(product.ImageSource); context.DeleteObject(product); context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Delete(int id) { using (var context = new SiteContainer()) { var article = context.Article.First(a => a.Id == id); if (!string.IsNullOrEmpty(article.ImageSource)) { IOHelper.DeleteFile("~/Content/Images", article.ImageSource); foreach (var thumbnail in SiteSettings.Thumbnails) { IOHelper.DeleteFile("~/ImageCache/" + thumbnail.Key, article.ImageSource); } } context.DeleteObject(article); context.SaveChanges(); return RedirectToAction("Articles", "Home", new { area = "" }); } }
public ActionResult Delete(int id) { using (var context = new SiteContainer()) { var banner = context.Banner.First(b => b.Id == id); IOHelper.DeleteFile("~/Content/Images", banner.ImageSource); foreach (var thumbnail in SiteSettings.Thumbnails) { IOHelper.DeleteFile("~/ImageCache/" + thumbnail.Key, banner.ImageSource); } context.DeleteObject(banner); context.SaveChanges(); return RedirectToAction("Index"); } }