public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IIndexBuilder indexBuilder, ILogger <Startup> logger)
        {
            indexBuilder.Build();

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "CoursesAPI v1");
                c.SwaggerEndpoint("/swagger/operations/swagger.json", "Operations v1");
                c.RoutePrefix = string.Empty;
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.ConfigureExceptionHandler(logger);

            app.UseAuthentication();

            if (!_configuration["Environment"].Equals("DEV", StringComparison.CurrentCultureIgnoreCase))
            {
                app.UseHealthChecks();
            }

            app.UseRouting();
            app.UseEndpoints(builder =>
            {
                builder.MapControllerRoute(
                    name: "default",
                    pattern: "api/{controller=Standards}/{action=Index}/{id?}");
            });
        }
Exemple #2
0
        public async Task <Unit> Handle(ImportDataCommand request, CancellationToken cancellationToken)
        {
            var importStartTime = DateTime.Now;

            var standardsImportTask  = _standardsImportService.ImportDataIntoStaging();
            var larsImportTask       = _larsImportService.ImportDataIntoStaging();
            var frameworksImportTask = _frameworksImportService.ImportDataIntoStaging();

            await Task.WhenAll(larsImportTask, standardsImportTask, frameworksImportTask);

            var tasks = new List <Task>();

            var frameworkImportResponse = frameworksImportTask.Result;

            if (frameworkImportResponse.Success)
            {
                tasks.Add(_frameworksImportService.LoadDataFromStaging(importStartTime, frameworkImportResponse.LatestFile));
            }

            tasks.Add(_standardsImportService.LoadDataFromStaging(importStartTime));

            await Task.WhenAll(tasks);

            var larsImportResponse = larsImportTask.Result;

            if (larsImportResponse.Success)
            {
                await _larsImportService.LoadDataFromStaging(importStartTime, larsImportResponse.FileName);
            }

            _indexBuilder.Build();

            return(Unit.Value);
        }