public ActionResult Create(Kisi K, HttpPostedFileBase ImageUpload) { try { byte[] ImageByteArray; using (Stream inputStream = ImageUpload.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } ImageByteArray = memoryStream.ToArray(); } if (ModelState.IsValid) { K.Photo = ImageByteArray; KY.KisiEkle(K); return RedirectToAction("Index"); } else { ViewBag.Hata = "Kayıt Başarısız"; return View(); } } catch { return View(); } }
public ActionResult Edit(Kisi collection, HttpPostedFileBase ImageUpload) { try { if (ImageUpload!=null) { byte[] ImageByteArray; using (Stream inputStream = ImageUpload.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } ImageByteArray = memoryStream.ToArray(); } Kisi K = KY.KisiGuncelle(collection, ImageByteArray); return View("Edit",K); } else { Kisi K = KY.KisiGuncelle(collection, null); return View("Edit", K); } } catch { return RedirectToAction("Index","Admin"); } }
public Kisi KisiGuncelle(Kisi collection, byte[] ImageUpload) { Kisi K = GetirKisiler(collection.Id); K.Aciklama = collection.Aciklama; K.Adi = collection.Adi; K.AktifMi = collection.AktifMi; K.DogumTarihi = collection.DogumTarihi; K.Soyad = collection.Soyad; if (ImageUpload!=null) { K.Photo = ImageUpload; } Rep.UpdateSaveChanges(); return K; }
public void KisiEkle(Kisi K1) { Rep.Add(K1); }