public ActionResult DeleteConfirmed(int id) { KindOfSchool kindOfSchool = db.KindOfSchools.Find(id); kindOfSchool.Is_Deleted = true; db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: KindOfSchools/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(RedirectToAction("errorpage", "home")); } KindOfSchool kindOfSchool = db.KindOfSchools.Find(id); if (kindOfSchool == null) { return(RedirectToAction("errorpage", "home")); } return(View(kindOfSchool)); }
public ActionResult Create(KindOfSchool kindOfSchool) { if (ModelState.IsValid) { var data = db.KindOfSchools.Where(a => a.Is_Deleted != true && a.KindOfSchollName == kindOfSchool.KindOfSchollName).SingleOrDefault(); if (data != null) { ViewBag.school = Languages.Language.SchoolErr; return(View(kindOfSchool)); } db.KindOfSchools.Add(kindOfSchool); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(kindOfSchool)); }
public ActionResult Edit(KindOfSchool kindOfSchool) { if (ModelState.IsValid) { var data = db.KindOfSchools.Where(a => a.Id != kindOfSchool.Id && a.Is_Deleted != true); foreach (var item in data) { if (item.KindOfSchollName == kindOfSchool.KindOfSchollName) { ViewBag.school = Languages.Language.SchoolErr; return(View(kindOfSchool)); } } var old = db.KindOfSchools.Find(kindOfSchool.Id); old.KindOfSchollName = kindOfSchool.KindOfSchollName; old.KindOfSchollNameArabic = kindOfSchool.KindOfSchollNameArabic; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(kindOfSchool)); }