public ActionResult EditSafetyCode([Bind(Include = "SafetyCodeGUID,Type,SubType,OshaCode,Description")] SafetyCode editSafetyCode) { if (Session["username"] != null && (Convert.ToInt32(Session["department"]) == 4500 || Convert.ToInt32(Session["department"]) == 10000)) { using (TrailerEntities db = new TrailerEntities()) { var code = db.SafetyCodes.FirstOrDefault(c => c.SafetyCodeGUID == editSafetyCode.SafetyCodeGUID); code.Type = editSafetyCode.Type; code.SubType = editSafetyCode.SubType; code.OshaCode = editSafetyCode.OshaCode; code.Description = editSafetyCode.Description; code.TypeSubType = editSafetyCode.Type + " - " + editSafetyCode.SubType; db.SaveChanges(); return(RedirectToAction(actionName: "SafetyCodes", controllerName: "Safety")); } } else if (Convert.ToInt32(Session["department"]) != constant.DEPARTMENT_HR_SAFETY || Convert.ToInt32(Session["department"]) != constant.DEPARTMENT_SUPER_ADMIN) { return(RedirectToAction(actionName: "InsufficientPermissions", controllerName: "Error")); } else { return(RedirectToAction(actionName: "SignIn", controllerName: "Users")); } }
public ActionResult CreateSafetyCode([Bind(Include = "Type,SubType,OshaCode,Description")] SafetyCode createSafetyCode) { if (Session["username"] != null && (Convert.ToInt32(Session["department"]) == 4500 || Convert.ToInt32(Session["department"]) == 10000)) { using (TrailerEntities db = new TrailerEntities()) { SafetyCode newCode = new SafetyCode() { Type = createSafetyCode.Type, SubType = createSafetyCode.SubType, OshaCode = createSafetyCode.OshaCode, Description = createSafetyCode.Description, TypeSubType = createSafetyCode.Type + " - " + createSafetyCode.SubType, Status = "ACTIVE", }; db.SafetyCodes.Add(newCode); db.SaveChanges(); return(RedirectToAction(actionName: "SafetyCodes", controllerName: "Safety")); } } else if (Convert.ToInt32(Session["department"]) != constant.DEPARTMENT_HR_SAFETY || Convert.ToInt32(Session["department"]) != constant.DEPARTMENT_SUPER_ADMIN) { return(RedirectToAction(actionName: "InsufficientPermissions", controllerName: "Error")); } else { return(RedirectToAction(actionName: "SignIn", controllerName: "Users")); } }