示例#1
0
        public ActionResult DeleteConfirmed(int id)
        {
            KindOfSchool kindOfSchool = db.KindOfSchools.Find(id);

            kindOfSchool.Is_Deleted = true;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
        // 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));
        }
示例#3
0
        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));
        }
示例#4
0
 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));
 }