public static ClsReturnValues setState(ClsState obj, Guid SessionID) { ClsReturnValues lst = new ClsReturnValues(); using (var db = new tdoEntities()) { lst = db.uspAddEditState(obj.stateID, obj.stateName, obj.stateCode, obj.createdByID, SessionID).FirstOrDefault(); } return lst; }
public JsonResult setState(string stateID, string stateName, string stateCode) { 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(stateID) == 0 && !addableForms.Contains("State")) { return Json(new { id = 0, isSuccess = false, msg = "You are not allowed to add new records." }); } else if (int.Parse(stateID) != 0 && !editableForms.Contains("State")) { return Json(new { id = 0, isSuccess = false, msg = "You are not allowed to edit records." }); } if (stateID == "") { stateID = "0"; } Guid Session = new Guid(GetSession()); //do not hard code session ID and createdbyID int _id = 0; try { _id = int.Parse(stateID.Trim()); } catch { } ClsState obj = new ClsState() { stateID = _id, stateName = stateName, stateCode = stateCode, createdByID = GetID(), sessionID = Session }; ClsReturnValues k = Administration.setState(obj, Session); return Json(new { id = k.ID, isSuccess = k.IsSuccess ?? false ? 1 : 0, msg = k.Response }); }