public ActionResult Edit(Ders model, HttpPostedFileBase file) { if (ModelState.IsValid) { using (EgitimUygulamasiDBContext db = new EgitimUygulamasiDBContext()) { if (db.Ders.SingleOrDefault(x => x.DersAdi.Equals(model.DersAdi) && x.ID != model.ID) == null) { db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ViewBag.Message = $"<div class='alert alert-success'><strong>Başarılı!</strong> Ders Başarıyla Güncellendi... </div>"; ModelState.Clear(); } else { ViewBag.Message = $"<div class='alert alert-danger'><strong>Hata!</strong> Bu ders adı zaten kullanılıyor... </div>"; } } } return(View(model)); }
public ActionResult Edit(Kullanici model) { if (ModelState.IsValid) { using (EgitimUygulamasiDBContext db = new EgitimUygulamasiDBContext()) { if (db.Kullanici.SingleOrDefault(x => x.KullaniciAdi.Equals(model.KullaniciAdi) && x.ID != model.ID) == null) { ViewBag.Users = db.Konu.ToList(); db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ViewBag.Message = $"<div class='alert alert-success'><strong>Başarılı!</strong> Konu Başarıyla Güncellendi... </div>"; ModelState.Clear(); } else { ViewBag.Message = $"<div class='alert alert-danger'><strong>Hata!</strong> Bu konu adı zaten kullanılıyor... </div>"; } } } return(View(model)); }