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 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); } }