public static ClsReturnValues setForms(ClsForms obj) { ClsReturnValues lst = new ClsReturnValues(); using (var db = new tdoEntities()) { lst = db.uspAddEditForms(obj.formID,obj.menuItemID,obj.formName,obj.formDescription,obj.createdByID, obj.sessionID).FirstOrDefault(); } return lst; }
public JsonResult setForms(string formID, string menuItemID, string formName, string formDescription) { List<ClsUserDisplay> userDisplay = new List<ClsUserDisplay>(); using (tdoEntities db = new tdoEntities()) { userDisplay = db.uspGetUserDisplay(GetID()).ToList<ClsUserDisplay>(); } List<string> editableForms = Restriction.GetEditableForms(userDisplay); List<string> addableForms = Restriction.GetAddableForms(userDisplay); if (int.Parse(formID) == 0 && !addableForms.Contains("Forms")) { return Json(new { id = 0, isSuccess = false, msg = "You are not allowed to add new records." }); } else if (int.Parse(formID) != 0 && !editableForms.Contains("Forms")) { return Json(new { id = 0, isSuccess = false, msg = "You are not allowed to edit records." }); } if (formID == "") { formID = "0"; } Guid Session = new Guid(GetSession()); //do not hard code session ID and createdbyID int _id = 0; try { _id = int.Parse(formID.Trim()); } catch { } ClsForms obj = new ClsForms() { formID = _id, menuItemID = int.Parse(menuItemID), formName = formName, formDescription = formDescription, createdByID = GetID(), sessionID = Session }; ClsReturnValues k = Administration.setForms(obj); return Json(new { id = k.ID, isSuccess = k.IsSuccess ?? false ? 1 : 0, msg = k.Response }); }