Beispiel #1
0
        public void RemoveRights(Account tenant, ETenantRights rights)
        {
            if (tenant == null)
            {
                throw new ArgumentNullException(nameof(tenant));
            }

            if (!Enum.IsDefined(typeof(ETenantRights), rights))
            {
                throw new InvalidEnumArgumentException(nameof(rights), (int)rights, typeof(ETenantRights));
            }

            TenantRight current = TenantRights.FirstOrDefault(x => (x != null) && (x.TenantId == tenant.Id));

            if (current == null)
            {
                return;
            }

            current.Remove(rights);
            if (current.Rights.HasNoFlags <ETenantRights>())
            {
                TenantRights.Remove(current);
            }
        }
            public TenantRight(ETenantRights rights, Account tenant)
            {
                if (!Enum.IsDefined(typeof(ETenantRights), rights))
                {
                    throw new InvalidEnumArgumentException(nameof(rights), (int)rights, typeof(ETenantRights));
                }

                Rights = rights;
                Tenant = tenant ?? throw new ArgumentNullException(nameof(tenant));
            }
Beispiel #3
0
        public void AddTenantRights(Account tenant, ETenantRights rights)
        {
            if (tenant == null)
            {
                throw new ArgumentNullException(nameof(tenant));
            }

            TenantRight current = TenantRights.FirstOrDefault(x => x.TenantId == tenant.Id);

            if (current == null)
            {
                TenantRights.Add(new TenantRight(rights, tenant));
            }
            else
            {
                current.Add(rights);
            }
        }
 public void Remove(ETenantRights rights) => Rights &= ~rights;
 public bool HasRights(ETenantRights rights) => !IsBanned() && Rights.HasFlag(rights);
 public void Add(ETenantRights rights) => Rights |= rights;