コード例 #1
0
        public static ClsReturnValues setRegion(ClsRegion obj, Guid SessionID)
        {
            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {

                lst = db.uspAddEditRegion(obj.regionID, obj.regionName, obj.createdByID, SessionID).FirstOrDefault();
            }
            return lst;
        }
コード例 #2
0
        public JsonResult setRegion(string regionID, string regionName)
        {
            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(regionID) == 0 && !addableForms.Contains("Region"))
            {
                return Json(new { id = 0, isSuccess = false, msg = "You are not allowed to add new records." });
            }
            else if (int.Parse(regionID) != 0 && !editableForms.Contains("Region"))
            {
                return Json(new { id = 0, isSuccess = false, msg = "You are not allowed to edit records." });
            }

            if (regionID == "") { regionID = "0"; }

            Guid Session = new Guid(GetSession()); //do not hard code session ID and createdbyID
            int _id = 0;
            try { _id = int.Parse(regionID.Trim()); }
            catch { }
            ClsRegion obj = new ClsRegion()
            {
                regionID = _id,
                regionName = regionName,
                createdByID = GetID(),
                sessionID = Session
            };
            ClsReturnValues k = Administration.setRegion(obj, Session);
            return Json(new { id = k.ID, isSuccess = k.IsSuccess ?? false ? 1 : 0, msg = k.Response });
        }