예제 #1
0
        public int Save(BO.j04UserRole rec)
        {
            if (!_mother.CurrentUser.IsGURU())
            {
                if (rec.j04IsClientRole && (TestOnePerm(BO.UserPermFlag.MasterAdmin, rec) || TestOnePerm(BO.UserPermFlag.MasterReader, rec)))
                {
                    _db.CurrentUser.AddMessage("U [CLIENT] role musíte lze zaškrtnout pouze client oprávnění.");
                    return(0);
                }
                if (rec.j04IsClientRole == false && (TestOnePerm(BO.UserPermFlag.ClientAdmin, rec) || TestOnePerm(BO.UserPermFlag.ClientReader, rec)))
                {
                    _db.CurrentUser.AddMessage("U [MASTER] role musíte lze zaškrtnout pouze master oprávnění.");
                    return(0);
                }
            }

            var p = new DL.Params4Dapper();

            p.AddInt("pid", rec.j04ID);
            p.AddString("j04Name", rec.j04Name);
            p.AddInt("j04PermissionValue", rec.j04PermissionValue);
            p.AddBool("j04IsClientRole", rec.j04IsClientRole);

            return(_db.SaveRecord("j04UserRole", p.getDynamicDapperPars(), rec));
        }
예제 #2
0
        private bool TestOnePerm(BO.UserPermFlag oneperm, BO.j04UserRole rec)
        {
            int x = (int)oneperm;
            int y = x & rec.j04PermissionValue;

            if (y == x)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }