public ActionResult EditSubject(decimal id = 0) { SET_SUBJECT subject = db.SET_SUBJECT.Single(s => s.SUBJECT_NO == id); if (subject == null) { return(HttpNotFound()); } return(View(subject)); }
public ActionResult EditSubject(SET_SUBJECT subject) { if (subject != null) { decimal?USER_NO = Session["sess_USER_NO"] as decimal?; decimal?LOGON_NO = Session["sess_LOGON_NO"] as decimal?; try { db.SET_SUBJECT_UPDATE(subject.SUBJECT_NO, USER_NO, LOGON_NO, subject.SUBJECT_NAME, subject.SUBJECT_NAME_BNG, subject.SUBJECT_CODE, subject.SUBJECT_DESC, subject.IS_ACTIVE, subject.ACTIVE_FROM, subject.ACTIVE_TO, subject.SL_NUM); return(RedirectToAction("Index")); } catch (Exception ex) { if (ex.InnerException.Message.Contains("unique constraint")) { ModelState.AddModelError("SUBJECT_NAME", "Unique Constraint Violated. " + "Same Subject Name is not allowed for multiple subjects."); } else { ModelState.AddModelError("ACTIVE_TO", "An error occured while adding subject."); } } ViewBag.CLASS_NO = subject.CLASS_NO; return(View(subject)); } else { return(HttpNotFound()); } }