Ejemplo n.º 1
0
        public ActionResult OgrenciGorusDuzenle(OgrenciGorus ogr, HttpPostedFileBase file)
        {
            try
            {
                var _ogrgorusDuzenle = ent.OgrenciGorus.Where(x => x.ID == ogr.ID).FirstOrDefault();
                if (file != null && file.ContentLength > 0)
                {
                    MemoryStream memoryStream = file.InputStream as MemoryStream;
                    if (memoryStream == null)
                    {
                        memoryStream = new MemoryStream();
                        file.InputStream.CopyTo(memoryStream);
                    }
                    _ogrgorusDuzenle.Foto = memoryStream.ToArray();
                }
                _ogrgorusDuzenle.AdSoyad = ogr.AdSoyad;
                _ogrgorusDuzenle.Gorus = ogr.Gorus;
                ent.SaveChanges();
                return RedirectToAction("OgrenciGorusleri", "Admin");
            }
            catch (Exception ex)
            {
                throw new Exception("Güncellerken hata oluştu " + ex.Message);
            }

        }
Ejemplo n.º 2
0
 public ActionResult OgrenciGorusEkle(OgrenciGorus g, HttpPostedFileBase file)
 {
     try
     {
         OgrenciGorus _ogrgorus = new OgrenciGorus();
         if (file != null && file.ContentLength > 0)
         {
             MemoryStream memoryStream = file.InputStream as MemoryStream;
             if (memoryStream == null)
             {
                 memoryStream = new MemoryStream();
                 file.InputStream.CopyTo(memoryStream);
             }
             _ogrgorus.Foto = memoryStream.ToArray();
         }
         _ogrgorus.AdSoyad = g.AdSoyad;
         _ogrgorus.Gorus = g.Gorus;
         _ogrgorus.Tarih = DateTime.Now;
         ent.OgrenciGorus.Add(_ogrgorus);
         ent.SaveChanges();
         return RedirectToAction("OgrenciGorusleri", "Admin");
     }
     catch (Exception ex)
     {
         throw new Exception("Eklerken hata oluştu");
     }
 }