public IActionResult Update() { var importer = new PdfContentImporter(_configuration, _context, _environment, true); importer.Run(); return(Json(new { result = importer.Imported })); }
public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); var config = BuildConfiguration(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <AppDbContext>(); var hostingEnvironment = services.GetRequiredService <IHostingEnvironment>(); var pdfContentReader = new PdfContentImporter(config, context, hostingEnvironment); pdfContentReader.Run(); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } host.Run(); }