예제 #1
0
        public void Handle(TriggerUpdateOfRepositories cmd)
        {
            var aggregateRoot = _aggregateRootRepoForInstallations.GetApplication();

            cmd.InstallationIds.ForEach(id => {
                var client       = _githubClientFactory.NewInstallationAuthenticatedClient(id).Result;
                var repositories = client.GitHubApps.Installation.GetAllRepositoriesForCurrent().Result.Repositories;
                aggregateRoot.RefreshedInstallationRepositories(id, repositories.Select(_ => (RepositoryFullName)_.FullName));
            });
        }
        /// <summary>
        /// Handles an <see cref="TriggerUpdateOfRepositories" /> command
        /// </summary>
        /// <param name="cmd">an <see cref="TriggerUpdateOfRepositories" /> command</param>
        public void Handle(TriggerUpdateOfRepositories cmd)
        {
            var aggregateRoot = _aggregateRootRepoForInstallations.GetApplication();

            cmd.InstallationIds.ForEach(id => {
                try
                {
                    var client       = _githubClientFactory.NewInstallationAuthenticatedClient(id).Result;
                    var repositories = client.GitHubApps.Installation.GetAllRepositoriesForCurrent().Result.Repositories;
                    aggregateRoot.RefreshInstallationRepositories(id, repositories.Select(_ => (RepositoryFullName)_.FullName));
                }
                catch (NotFoundException)
                {
                    // This means that the installation no longer exists, i.e. has been removed
                    aggregateRoot.UnregisterInstallation(id);
                }
            });
        }