Exemplo n.º 1
0
 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 = "" });
     }
 }
Exemplo n.º 2
0
 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 = "" });
 }
Exemplo n.º 3
0
 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 });
     }
 }
Exemplo n.º 4
0
        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 });
            }
        }
Exemplo n.º 5
0
        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 });
            }
        }
Exemplo n.º 6
0
 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");
     }
 }
Exemplo n.º 7
0
        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 = "" });
            }
        }
Exemplo n.º 8
0
 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");
     }
 }