// GET: SchoolCertificateM_M/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("errorpage", "home")); } SchoolCertificateM_M schoolCertificateM_M = db.SchoolCertificateM_M.Find(id); if (schoolCertificateM_M == null) { return(RedirectToAction("errorpage", "home")); } ViewBag.CertificateId = new SelectList(db.Certificates.Where(a => a.Is_Deleted != true), "Id", "CirtificateTypeName"); ViewBag.SchoolId = new SelectList(db.Schools.Where(a => a.Is_Deleted != true), "Id", "SchoolName"); if (Session["lang"] != null) { if (Session["lang"].ToString().Equals("ar-EG")) { ViewBag.CertificateId = new SelectList(db.Certificates.Where(a => a.Is_Deleted != true), "Id", "CirtificateTypeNameArabic"); ViewBag.SchoolId = new SelectList(db.Schools.Where(a => a.Is_Deleted != true), "Id", "SchoolNameArabic"); } } return(View(schoolCertificateM_M)); }
public ActionResult DeleteConfirmed(int id) { SchoolCertificateM_M schoolCertificateM_M = db.SchoolCertificateM_M.Find(id); schoolCertificateM_M.Is_Deleted = true; db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: SchoolCertificateM_M/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(RedirectToAction("errorpage", "home")); } SchoolCertificateM_M schoolCertificateM_M = db.SchoolCertificateM_M.Find(id); if (schoolCertificateM_M == null) { return(RedirectToAction("errorpage", "home")); } return(View(schoolCertificateM_M)); }
public ActionResult Edit(SchoolCertificateM_M schoolCertificateM_M) { if (ModelState.IsValid) { var data = db.SchoolCertificateM_M.Where(a => a.Is_Deleted != true && a.Id != schoolCertificateM_M.Id); foreach (var item in data) { if (item.SchoolId == schoolCertificateM_M.SchoolId && item.CertificateId == schoolCertificateM_M.CertificateId) { ViewBag.errorMessage = "this certificate in already exsits in this school"; ViewBag.CertificateId = new SelectList(db.Certificates.Where(a => a.Is_Deleted != true), "Id", "CirtificateTypeName"); ViewBag.SchoolId = new SelectList(db.Schools.Where(a => a.Is_Deleted != true), "Id", "SchoolName"); if (Session["lang"] != null) { if (Session["lang"].ToString().Equals("ar-EG")) { ViewBag.CertificateId = new SelectList(db.Certificates.Where(a => a.Is_Deleted != true), "Id", "CirtificateTypeNameArabic"); ViewBag.SchoolId = new SelectList(db.Schools.Where(a => a.Is_Deleted != true), "Id", "SchoolNameArabic"); } } return(View(schoolCertificateM_M)); } } var old = db.SchoolCertificateM_M.Find(schoolCertificateM_M.Id); old.SchoolId = schoolCertificateM_M.SchoolId; old.CertificateId = schoolCertificateM_M.CertificateId; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.errorMessage = "this certificate in already exsits in this school"; ViewBag.CertificateId = new SelectList(db.Certificates.Where(a => a.Is_Deleted != true), "Id", "CirtificateTypeName"); ViewBag.SchoolId = new SelectList(db.Schools.Where(a => a.Is_Deleted != true), "Id", "SchoolName"); if (Session["lang"] != null) { if (Session["lang"].ToString().Equals("ar-EG")) { ViewBag.CertificateId = new SelectList(db.Certificates.Where(a => a.Is_Deleted != true), "Id", "CirtificateTypeNameArabic"); ViewBag.SchoolId = new SelectList(db.Schools.Where(a => a.Is_Deleted != true), "Id", "SchoolNameArabic"); } } return(View(schoolCertificateM_M)); }
public ActionResult Create(SchoolCertificateM_M schoolCertificateM_M) { if (ModelState.IsValid) { var data = db.SchoolCertificateM_M.Where(a => a.Is_Deleted != true && a.SchoolId == schoolCertificateM_M.SchoolId && a.CertificateId == schoolCertificateM_M.CertificateId).SingleOrDefault(); if (data != null) { ViewBag.errorMessage = "this certificate in already exsits in this school"; ViewBag.CertificateId = new SelectList(db.Certificates.Where(a => a.Is_Deleted != true), "Id", "CirtificateTypeName"); ViewBag.SchoolId = new SelectList(db.Schools.Where(a => a.Is_Deleted != true), "Id", "SchoolName"); if (Session["lang"] != null) { if (Session["lang"].ToString().Equals("ar-EG")) { ViewBag.CertificateId = new SelectList(db.Certificates.Where(a => a.Is_Deleted != true), "Id", "CirtificateTypeNameArabic"); ViewBag.SchoolId = new SelectList(db.Schools.Where(a => a.Is_Deleted != true), "Id", "SchoolNameArabic"); } } return(View(schoolCertificateM_M)); } db.SchoolCertificateM_M.Add(schoolCertificateM_M); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.errorMessage = "this certificate in already exsits in this school"; ViewBag.CertificateId = new SelectList(db.Certificates.Where(a => a.Is_Deleted != true), "Id", "CirtificateTypeName"); ViewBag.SchoolId = new SelectList(db.Schools.Where(a => a.Is_Deleted != true), "Id", "SchoolName"); if (Session["lang"] != null) { if (Session["lang"].ToString().Equals("ar-EG")) { ViewBag.CertificateId = new SelectList(db.Certificates.Where(a => a.Is_Deleted != true), "Id", "CirtificateTypeNameArabic"); ViewBag.SchoolId = new SelectList(db.Schools.Where(a => a.Is_Deleted != true), "Id", "SchoolNameArabic"); } } return(View(schoolCertificateM_M)); }