예제 #1
0
        public ActionResult DeletePost(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var DeleteNews = db.News.FirstOrDefault(f => f.Id == id);

                if (DeleteNews == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    var imgName = Path.GetFileName(DeleteNews.ImagePath);
                    var imgPath = ProsesImageFile.ImagePath(imgName, "/Image/News");
                    ProsesImageFile.DeleteImageFile(imgPath);

                    db.News.Remove(DeleteNews);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
        }
예제 #2
0
        public ActionResult Delete(int?Id)
        {
            if (Id == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var DeleteCarusel = db.Carusels.FirstOrDefault(f => f.Id == Id);

                if (DeleteCarusel == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    var imgName = Path.GetFileName(DeleteCarusel.ImagePath);
                    var imgPath = ProsesImageFile.ImagePath(imgName, "/Image/Carusel");
                    ProsesImageFile.DeleteImageFile(imgPath);

                    db.Carusels.Remove(DeleteCarusel);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
        }
예제 #3
0
 public ActionResult DeletePost(int id)
 {
     try
     {
         var deletShop = db.Shops.FirstOrDefault(f => f.Id == id);
         var imgName   = Path.GetFileName(deletShop.ImagePath);
         var imgPath   = ProsesImageFile.ImagePath(imgName, "/Image/Shops");
         ProsesImageFile.DeleteImageFile(imgPath);
         db.Shops.Remove(deletShop);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(HttpNotFound());
     }
 }
예제 #4
0
 public ActionResult DeletePost(int id)
 {
     try
     {
         var deletCountry = db.Countries.FirstOrDefault(f => f.Id == id);
         var imgName      = Path.GetFileName(deletCountry.ImagePath);
         var imgPath      = ProsesImageFile.ImagePath(imgName, "/Image/Country");
         if (System.IO.File.Exists(imgPath))
         {
             ProsesImageFile.DeleteImageFile(imgPath);
         }
         db.Countries.Remove(deletCountry);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(HttpNotFound());
     }
 }