Beispiel #1
0
        public ActionResult ResimSil(int id)
        {
            Resim dbResim = _resimRepository.GetById(id);

            if (dbResim == null)
            {
                throw new Exception("Resim Bulunamadı");
            }
            string   file_name = dbResim.ResimUrl;
            string   path      = Server.MapPath(file_name);
            FileInfo file      = new FileInfo(path);

            if (file.Exists)
            {
                file.Delete();
            }
            _resimRepository.Delete(id);
            _resimRepository.Save();
            TempData["Bilgi"] = "Resim Silme İşlemi Başarılı";
            return(RedirectToAction("Index", "Haber"));
        }
        public ActionResult ResimSil(int id)
        {
            Resim dbResim = _resimRepository.GetById(id);

            if (dbResim == null)
            {
                TempData["Bilgi"] = "Resim bulunamadı !";
                return(RedirectToAction("Index", "Arac"));
            }
            string   file_name = dbResim.ResimUrl;
            string   path      = Server.MapPath(file_name);
            FileInfo file      = new FileInfo(path);

            if (file.Exists)
            {
                file.Delete();
            }
            _resimRepository.Delete(id);
            _resimRepository.Save();
            TempData["Bilgi"] = "Resim silme işleminiz başarılı!";
            return(RedirectToAction("Index", "Arac"));
        }
Beispiel #3
0
 public Resim GetById(int id)
 {
     return(_resimRepository.GetById(id));
 }