示例#1
0
        public void CreatePermission(Users User, Props.Permission Permission)
        {
            using (var db = new CoreContext())
            {
                Models.UserPermissions permission = new Models.UserPermissions()
                {
                    PermissionName  = Permission.Name(),
                    PermissionValue = Permission.Value(),
                    UserId          = User.UserId,
                    Users           = User
                };

                db.UserPermissions.Add(permission);
                db.SaveChanges();
            }
        }
示例#2
0
        public void UpdatePermission(Users User, Props.Permission Permission)
        {
            using (var db = new CoreContext())
            {
                var permSearch = db.UserPermissions.SingleOrDefault(x => x.UserId == User.UserId && x.PermissionName == Permission.Name());
                permSearch.PermissionValue = Permission.Value();

                db.SaveChanges();
            }
        }
示例#3
0
 public Props.Permission GetPermission(Users User, Props.Permission Permission, bool includeNativePermissions = false)
 {
     using (var db = new CoreContext())
     {
         var permSearch = db.UserPermissions.Single(x => x.UserId == User.UserId && x.PermissionName == Permission.Name());
         return(new Props.Permission(permSearch.PermissionName, permSearch.PermissionValue));
     }
 }
示例#4
0
        public void DeletePermission(Users User, Props.Permission Permission)
        {
            using (var db = new CoreContext())
            {
                var permSearch = db.UserPermissions.SingleOrDefault(x => x.UserId == User.UserId && x.PermissionName == Permission.Name());

                if (permSearch != null)
                {
                    db.UserPermissions.Remove(permSearch);
                    db.SaveChanges();
                }
            }
        }