Пример #1
0
        public ActionResult OgretimElemaniDuzenle(OgretimElemani ogrelemani, HttpPostedFileBase file)
        {
            try
            {
                var _ogretimelemaniDuzenle = ent.OgretimElemani.Where(x => x.OgretimElemanId == ogrelemani.OgretimElemanId).FirstOrDefault();
                if (file != null && file.ContentLength > 0)
                {
                    MemoryStream memoryStream = file.InputStream as MemoryStream;
                    if (memoryStream == null)
                    {
                        memoryStream = new MemoryStream();
                        file.InputStream.CopyTo(memoryStream);
                    }
                    _ogretimelemaniDuzenle.Foto = memoryStream.ToArray();
                }
                _ogretimelemaniDuzenle.Ad = ogrelemani.Ad;
                _ogretimelemaniDuzenle.Soyad = ogrelemani.Soyad;
                _ogretimelemaniDuzenle.Telefon = ogrelemani.Telefon;
                _ogretimelemaniDuzenle.Eposta = ogrelemani.Eposta;
                _ogretimelemaniDuzenle.Ozgecmis = ogrelemani.Ozgecmis;
                ent.SaveChanges();
                return RedirectToAction("OgretimElemani", "Admin");
            }
            catch (Exception ex)
            {
                throw new Exception("Güncellerken hata oluştu " + ex.Message);
            }

        }
Пример #2
0
 public ActionResult OgretimElemaniEkle(OgretimElemani ogreleman, HttpPostedFileBase file)
 {
     try
     {
         OgretimElemani _ogretimelemani = new OgretimElemani();
         if (file != null && file.ContentLength > 0)
         {
             MemoryStream memoryStream = file.InputStream as MemoryStream;
             if (memoryStream == null)
             {
                 memoryStream = new MemoryStream();
                 file.InputStream.CopyTo(memoryStream);
             }
             _ogretimelemani.Foto = memoryStream.ToArray();
         }
         _ogretimelemani.Ad = ogreleman.Ad;
         _ogretimelemani.Soyad = ogreleman.Soyad;
         _ogretimelemani.Telefon = ogreleman.Telefon;
         _ogretimelemani.Eposta = ogreleman.Eposta;
         _ogretimelemani.Ozgecmis = ogreleman.Ozgecmis;
         ent.OgretimElemani.Add(_ogretimelemani);
         ent.SaveChanges();
         return RedirectToAction("OgretimElemani", "Admin");
     }
     catch (Exception ex)
     {
         throw new Exception("Eklerken hata oluştu");
     }
 }