/// <summary>
        /// Initializes a new instance of the <see cref="AwardNominationSearchService"/> class.
        /// </summary>
        /// <param name="searchServiceOptions">A set of key/value application configuration properties.</param>
        /// <param name="storageOptions">A set of key/value application storage configuration properties.</param>
        /// <param name="nominateAwardStorageProvider">Provider to store on nomination details in Azure table storage.</param>
        public AwardNominationSearchService(
            IOptionsMonitor <SearchServiceOptions> searchServiceOptions,
            IOptionsMonitor <StorageOptions> storageOptions,
            IAwardNominationStorageProvider nominateAwardStorageProvider)
        {
            searchServiceOptions = searchServiceOptions ?? throw new ArgumentNullException(nameof(searchServiceOptions));
            storageOptions       = storageOptions ?? throw new ArgumentNullException(nameof(storageOptions));

            this.searchServiceOptions = searchServiceOptions.CurrentValue;
            var searchDnsSuffix = this.searchServiceOptions.IsGccHybridDeployment ? "search.azure.us" : "search.windows.net";

            this.searchServiceClient = new SearchServiceClient(
                this.searchServiceOptions.SearchServiceName,
                new SearchCredentials(this.searchServiceOptions.SearchServiceAdminApiKey))
            {
                SearchDnsSuffix = searchDnsSuffix,
            };
            this.searchIndexClient = new SearchIndexClient(
                this.searchServiceOptions.SearchServiceName,
                NominateDetailIndexName,
                new SearchCredentials(this.searchServiceOptions.SearchServiceQueryApiKey))
            {
                SearchDnsSuffix = searchDnsSuffix,
            };
            this.nominateAwardStorageProvider = nominateAwardStorageProvider;
            this.initializeTask = new Lazy <Task>(() => this.InitializeAsync(storageOptions.CurrentValue.ConnectionString));
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NominationsController"/> class.
 /// </summary>
 /// <param name="logger">Provider to store logs in Azure Application Insights.</param>
 /// <param name="storageProvider">Nominate award detail storage provider.</param>
 /// <param name="endorseStorageProvider">Endorsement storage provider.</param>
 /// <param name="teamsInfoHelper">Provider to fetch team details from bot adapter.</param>
 public NominationsController(
     ILogger <NominationsController> logger,
     IAwardNominationStorageProvider storageProvider,
     IEndorsementsStorageProvider endorseStorageProvider,
     ITeamsInfoHelper teamsInfoHelper)
 {
     this.logger                 = logger;
     this.storageProvider        = storageProvider;
     this.endorseStorageProvider = endorseStorageProvider;
     this.teamsInfoHelper        = teamsInfoHelper;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AwardNominationSearchService"/> class.
        /// </summary>
        /// <param name="searchServiceOptions">A set of key/value application configuration properties.</param>
        /// <param name="storageOptions">A set of key/value application storage configuration properties.</param>
        /// <param name="nominateAwardStorageProvider">Provider to store on nomination details in Azure table storage.</param>
        public AwardNominationSearchService(
            IOptionsMonitor <SearchServiceOptions> searchServiceOptions,
            IOptionsMonitor <StorageOptions> storageOptions,
            IAwardNominationStorageProvider nominateAwardStorageProvider)
        {
            searchServiceOptions = searchServiceOptions ?? throw new ArgumentNullException(nameof(searchServiceOptions));
            storageOptions       = storageOptions ?? throw new ArgumentNullException(nameof(storageOptions));

            this.searchServiceOptions = searchServiceOptions.CurrentValue;
            string searchServiceValue = this.searchServiceOptions.SearchServiceName;

            this.searchServiceClient = new SearchServiceClient(
                searchServiceValue,
                new SearchCredentials(this.searchServiceOptions.SearchServiceAdminApiKey));
            this.searchIndexClient = new SearchIndexClient(
                searchServiceValue,
                NominateDetailIndexName,
                new SearchCredentials(this.searchServiceOptions.SearchServiceQueryApiKey));
            this.nominateAwardStorageProvider = nominateAwardStorageProvider;
            this.initializeTask = new Lazy <Task>(() => this.InitializeAsync(storageOptions.CurrentValue.ConnectionString));
        }