Esempio n. 1
0
        public async Task AddSubscriptionAsync(Subscription subscription)
        {
            if (subscription == null)
            {
                throw new ArgumentNullException(nameof(subscription));
            }

            var client = await clientReadOnlyRepository.GetClientAsync(subscription.ClientId);

            if (client == null)
            {
                throw new ClientCoreException(ClientCoreError.ClientNotFound);
            }

            var hasSubscriptionActive = client.Subscriptions.Any(c => c.Active);

            if (hasSubscriptionActive)
            {
                throw new SubscriptionCoreException().AddError(SubscriptionCoreError.SubscriptionIsActive);
            }

            await subscriptionWriteOnlyRepository.AddSubscriptionAsync(subscription);
        }
Esempio n. 2
0
        public async Task <Client> GetClientAsync(Guid clientId)
        {
            var client = await clientReadOnlyRepository.GetClientAsync(clientId);

            return(client);
        }