public async Task <IActionResult> Edit(Yayin yayin, IFormFile image)
        {
            if (image != null)
            {
                if (System.IO.File.Exists(_env.WebRootPath + yayin.ImageUrl))
                {
                    System.IO.File.Delete(_env.WebRootPath + yayin.ImageUrl);
                }
                if (image == null || image.Length == 0)
                {
                    return(Content("not image selected"));
                }

                var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/image/Yayincilar", image.FileName);

                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await image.CopyToAsync(stream);
                }

                yayin.ImageUrl = "/image/Yayincilar/" + image.FileName;
            }

            _yayinService.Update(yayin);
            return(RedirectToAction("Index"));
        }
示例#2
0
 public ActionResult YayinDeleteConfirmed(int id)
 {
     if (Session["UserSession"] == null)
     {
         return(RedirectToAction("PermissionDenied", "Admin"));
     }
     else
     {
         Yayin yayin = db.Yayin.Find(id);
         db.Yayin.Remove(yayin);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
示例#3
0
        // GET: Yayinlar/Details/5
        public ActionResult YayinDetails(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Yayin yayin = db.Yayin.Find(id);

            if (yayin == null)
            {
                return(HttpNotFound());
            }
            return(View(yayin));
        }
示例#4
0
        public ActionResult YayinEdit([Bind(Include = "Yayin_ID,YayinTip_ID,Yayin_Baslik,Yayin_Foto,Yayin_Icerik,Yayin_Ozet,YayinEtiket,Yayin_Yazar,Yayin_Dosya,Yayin_Tarih")] Yayin yayin, HttpPostedFileBase YayinFoto, HttpPostedFileBase YayinDosya)
        {
            if (Session["UserSession"] == null)
            {
                return(RedirectToAction("PermissionDenied", "Admin"));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    if (YayinFoto.FileName != null && YayinDosya.FileName != null)
                    {
                        FileInfo fotoBilgisi     = new FileInfo(YayinFoto.FileName);
                        string   yeniFotoBilgisi = Guid.NewGuid().ToString("n") + fotoBilgisi.Extension;



                        FileInfo dosyaBilgisi     = new FileInfo(YayinDosya.FileName);
                        string   yeniDosyaBilgisi = Guid.NewGuid().ToString("n") + dosyaBilgisi.Extension;

                        YayinFoto.SaveAs(Server.MapPath("~/Content/Upload/Yayin/Foto/" + yeniFotoBilgisi));
                        YayinDosya.SaveAs(Server.MapPath("~/Content/Upload/Yayin/Dosya/" + yeniDosyaBilgisi));

                        yayin.Yayin_Foto  = yeniFotoBilgisi;
                        yayin.Yayin_Dosya = yeniDosyaBilgisi;


                        db.Entry(yayin).State = EntityState.Modified;
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Lütfen yayin için düzgün veri girin.");
                        return(View(yayin));
                    }
                    //db.Entry(yayin).State = EntityState.Modified;
                    //db.SaveChanges();
                    //return RedirectToAction("Index");
                }
                ViewBag.YayinTip_ID = new SelectList(db.YayinTip, "YayinTip_ID", "YayinTip_Adi", yayin.YayinTip_ID);
                return(View(yayin));
            }
        }
        public async Task <IActionResult> Create(IFormFile image, Yayin yayin)
        {
            if (image == null || image.Length == 0)
            {
                return(Content("not image selected"));
            }

            var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/image/Yayincilar", image.FileName);

            using (var stream = new FileStream(path, FileMode.Create))
            {
                await image.CopyToAsync(stream);
            }

            yayin.ImageUrl = "/image/Yayincilar/" + image.FileName;
            _yayinService.Add(yayin);

            return(RedirectToAction("Index"));
        }
示例#6
0
 // GET: Yayins/Details/5
 public ActionResult YayinDetails(int?id)
 {
     if (Session["UserSession"] == null)
     {
         return(RedirectToAction("PermissionDenied", "Admin"));
     }
     else
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Yayin yayin = db.Yayin.Find(id);
         if (yayin == null)
         {
             return(HttpNotFound());
         }
         return(View(yayin));
     }
 }
示例#7
0
 // GET: Yayins/Edit/5
 public ActionResult YayinEdit(int?id)
 {
     if (Session["UserSession"] == null)
     {
         return(RedirectToAction("PermissionDenied", "Admin"));
     }
     else
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Yayin yayin = db.Yayin.Find(id);
         if (yayin == null)
         {
             return(HttpNotFound());
         }
         ViewBag.YayinTip_ID = new SelectList(db.YayinTip, "YayinTip_ID", "YayinTip_Adi", yayin.YayinTip_ID);
         return(View(yayin));
     }
 }
示例#8
0
 public void Update(Yayin yayin)
 {
     _yayinDal.Update(yayin);
 }
示例#9
0
 public void Add(Yayin yayin)
 {
     _yayinDal.Add(yayin);
 }