Esempio n. 1
0
        public IActionResult DeleteProduct(ProductViewModel model)
        {
            var product = db.Products.Find(model.ProductId);

            if (product != null)
            {
                if (product.ImagePath != null)
                {
                    if (System.IO.File.Exists(appEnvironment.WebRootPath + product.ImagePath))
                    {
                        System.IO.File.Delete(appEnvironment.WebRootPath + product.ImagePath);
                    }
                }
                db.Remove(product);
                db.SaveChanges();
            }
            return(RedirectToAction("ProductsList", "Admin"));
        }
Esempio n. 2
0
 public void RemoveDrink(Drink drink)
 {
     _context.Remove(drink);
     _context.SaveChanges();
 }