Beispiel #1
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Gerenciador Processo Api v1");
                c.RoutePrefix = string.Empty;
            });

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

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope();
            var dbContext    = serviceScope.ServiceProvider.GetService <IGerenciadorProcessosDbContext>();

            DbInitializerHelper.EnsureDatabase(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope());
        }
        public ActionResult Upload()
        {
            DbInitializer <ApplicationContext> initializer = new DbInitializer <ApplicationContext>();

            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = System.IO.Path.GetFileName(file.FileName);
                    var path     = System.IO.Path.Combine(Server.MapPath("~/App_Data/"), fileName);
                    file.SaveAs(path);

                    DbInitializerHelper.LoadChartOfAccountsFromFile(fileName, 100);
                }
            }
            return(RedirectToAction("Index"));
        }