示例#1
0
        public async Task UpdateMultiDatabseSubscriptionState(Office365SubscriptionState subscriptionState, List <string> office365SubscriptionIds)
        {
            var subscriptions = await _dbContext.Office365Subscriptions
                                .Where(s => office365SubscriptionIds.Any(x => x == s.Office365SubscriptionId)).ToListAsync();

            if (subscriptions == null || subscriptions.Count == 0)
            {
                throw new NullReferenceException($"Could not change subscription state to {subscriptionState} because subscription {string.Join(",", office365SubscriptionIds)} was not found");
            }

            subscriptions.ForEach(x => x.SubscriptionState = subscriptionState);

            await _dbContext.SaveChangesAsync();
        }
示例#2
0
        public async Task UpdateDatabseSubscriptionState(Office365SubscriptionState subscriptionState, string office365SubscriptionId)
        {
            var subscription = await _dbContext.Office365Subscriptions
                               .FirstOrDefaultAsync(s => s.Office365SubscriptionId == office365SubscriptionId);

            if (subscription == null)
            {
                throw new NullReferenceException($"Could not change subscription state to {subscriptionState} becaues subscription {office365SubscriptionId} was not found");
            }

            subscription.SubscriptionState = subscriptionState;

            await _dbContext.SaveChangesAsync();
        }