public void Delete(int id) { var prod = _service.GetProduct(id); string fileName = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["ImageFolder"]) + prod.Image; if (File.Exists(fileName)) { File.Delete(fileName); } _service.DeleteProduct(id); }
public ActionResult Delete(int id) { var prod = _service.GetProduct(id); string fileName = HttpContext.Server.MapPath(ConfigurationManager.AppSettings["ImageFolder"]) + prod.Image; if (System.IO.File.Exists(fileName)) { System.IO.File.Delete(fileName); } string path = HttpContext.Request.UrlReferrer.AbsolutePath; _service.DeleteProduct(id); return(Redirect(path)); }