Пример #1
0
        public ActionResult SlideDuzenle(Slider slide, HttpPostedFileBase file)
        {
            try
            {
                var _slideDuzenle = ent.Slider.Where(x => x.ID == slide.ID).FirstOrDefault();
                if (file != null && file.ContentLength > 0)
                {
                    MemoryStream memoryStream = file.InputStream as MemoryStream;
                    if (memoryStream == null)
                    {
                        memoryStream = new MemoryStream();
                        file.InputStream.CopyTo(memoryStream);
                    }
                    _slideDuzenle.SliderFoto = memoryStream.ToArray();
                }
                _slideDuzenle.SliderText = slide.SliderText;
                _slideDuzenle.BaslangicTarih = slide.BaslangicTarih;
                _slideDuzenle.BitisTarih = slide.BitisTarih;
                ent.SaveChanges();
                return RedirectToAction("Slider", "Admin");
            }
            catch (Exception ex)
            {
                throw new Exception("Güncellerken hata oluştu " + ex.Message);
            }

        }
Пример #2
0
 public ActionResult SlideEkle(Slider s, HttpPostedFileBase file)
 {
     try
     {
         Slider _slide = new Slider();
         if (file != null && file.ContentLength > 0)
         {
             MemoryStream memoryStream = file.InputStream as MemoryStream;
             if (memoryStream == null)
             {
                 memoryStream = new MemoryStream();
                 file.InputStream.CopyTo(memoryStream);
             }
             _slide.SliderFoto = memoryStream.ToArray();
         }
         _slide.SliderText = s.SliderText;
         _slide.BaslangicTarih = s.BaslangicTarih;
         _slide.BitisTarih = s.BitisTarih;
         ent.Slider.Add(_slide);
         ent.SaveChanges();
         return RedirectToAction("Slider", "Admin");
     }
     catch (Exception ex)
     {
         throw new Exception("Eklerken hata oluştu");
     }
 }