public static IIntegrationSystemService GetService(this IEnumerable <IIntegrationSystemService> services, Provider provider)
        {
            IIntegrationSystemService service = services.FirstOrDefault(s => s.Provider == provider);

            if (service == null)
            {
                throw new ArgumentException($"{nameof(IIntegrationSystemService)} implementation not found for '{provider}'.");
            }

            return(service);
        }
示例#2
0
        public async Task DeleteIntegrationAsync(string id)
        {
            Integration integration = await _integrationRepository.GetIntegrationAsync(id, _operationContext.UserId);

            if (integration != null)
            {
                IIntegrationSystemService integrationSystemService = _integrationSystemServices.GetService(integration.Provider);
                await integrationSystemService.DeleteIntegrationAsync(_operationContext.UserId);

                await _integrationRepository.DeleteIntegrationAsync(id, _operationContext.UserId);

                await _eventPublisher.PublishAsync(CreateIntegrationDeletedEvent(integration));
            }
        }
示例#3
0
        public async Task <Integration> CreateIntegrationAsync(ProviderRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            IIntegrationSystemService integrationSystemService = _integrationSystemServices.GetService(request.Provider);
            ProviderResult            creationResult           = await integrationSystemService.CreateIntegrationAsync(request);

            Integration integration = await _integrationRepository.CreateIntegrationAsync(
                _operationContext.UserId,
                creationResult.Provider,
                creationResult.ProviderUserId,
                creationResult.Data);

            await _eventPublisher.PublishAsync(CreateIntegrationCreatedEvent(integration));

            return(integration);
        }