示例#1
0
        public ActionResult ResimSil(int id)
        {
            Resim r = _resimRepository.GetByID(id);

            if (r == null)
            {
                throw new Exception("Resim bulunamadı");
            }
            string   dosyaAdi = r.ResimYolu;
            FileInfo file     = new FileInfo(Server.MapPath(dosyaAdi));

            if (file.Exists)
            {
                file.Delete();
            }
            _resimRepository.Delete(r.ID);
            _resimRepository.Save();
            return(RedirectToAction("Duzenle", "Haber", new { ID = r.HaberID }));
        }
示例#2
0
        public JsonResult DetayResimSil(int id)
        {
            var resim = _resimRepository.GetByID(id);

            if (resim == null)
            {
                throw new Exception("Resim bulunmadı");
            }
            try
            {
                _resimRepository.Delete(id);
                _resimRepository.Save();
                System.IO.File.Delete(Server.MapPath(resim.ResimYol));
                return(Json(new ResultJSON {
                    Success = true
                }));
            }
            catch
            {
                return(Json(new ResultJSON {
                    Success = false
                }));
            }
        }