Example #1
0
        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);
        }
Example #2
0
        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));
        }