Esempio n. 1
0
        public void AddPlayerPermission(int userId, string permission, bool allowed)
        {
            using (var session = CreateSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    SharpStarPermission perm = session.Query <SharpStarPermission>().SingleOrDefault(p => p.User.Id == userId && p.Permission == permission);

                    if (perm != null)
                    {
                        perm.Allowed = allowed;

                        session.SaveOrUpdate(perm);
                    }
                    else
                    {
                        session.Save(new SharpStarPermission {
                            User = GetUser(userId), Permission = permission, Allowed = allowed
                        });
                    }

                    transaction.Commit();
                }
            }
        }
Esempio n. 2
0
        public void DeletePlayerPermission(int userId, string permission)
        {
            using (var session = CreateSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    SharpStarPermission perm = session.Query <SharpStarPermission>().SingleOrDefault(p => p.User.Id == userId && p.Permission == permission);

                    if (perm != null)
                    {
                        session.Delete(perm);
                    }

                    transaction.Commit();
                }
            }
        }