public MainViewModel(Action onClose, IWindowFactory windowFactory, IPageFactory pageFactory) : base(onClose)
        {
            // Deletes existing database and seeds it with predefined data
            DataSeeder dataSeeder = new DataSeeder();

            dataSeeder.SeedAll();

            // Window services.
            _windowFactory = windowFactory;
            _pageFactory   = pageFactory;

            // Setup quotation page view
            QuotationPage         = _pageFactory.GetNewPageInstanceAsObject(PageType.QuotationPageView);
            _quotationPageService = _pageFactory.GetPageService(QuotationPage);

            // Setup customer page view
            CustomerPage         = _pageFactory.GetNewPageInstanceAsObject(PageType.CustomerPageView);
            _customerPageService = _pageFactory.GetPageService(CustomerPage);

            // Setup item page view
            ItemPage          = _pageFactory.GetNewPageInstanceAsObject(PageType.ItemPageView);
            _itemsPageService = _pageFactory.GetPageService(ItemPage);

            // Setup template page view
            TemplatePage         = _pageFactory.GetNewPageInstanceAsObject(PageType.TemplatePageView);
            _templatePageService = _pageFactory.GetPageService(TemplatePage);

            SelectedTabIndex = 0;
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeeder dataSeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            dataSeeder.SeedSuperUser().Wait();

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Exemplo n.º 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeeder dataSeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            dataSeeder.SeedSuperUser();

            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Exemplo n.º 4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeeder seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            // dotnet user-secrets set SeedUserPW <pw>
            var testUserPw = Configuration["SeedUserPW"];

            if (String.IsNullOrEmpty(testUserPw))
            {
                throw new Exception("Use secrets manager to set SeedUserPW \n" +
                                    "dotnet user-secrets set SeedUserPW <pw>");
            }

            seeder.SeedAsync(testUserPw).Wait();
        }
Exemplo n.º 5
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeeder seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseCustomHeadersMiddleware();
            app.UseMiddleware(typeof(LogExceptionHandlingMiddleware));
            app.UseStaticFiles();
            app.UseAuthentication();
            app.ConfigureUniversalCorsApplication();
            if (ConfigurationManager.UseSwagger)
            {
                app.ConfigureSwaggerApplication();
            }
            ConfigurationManager.ConfigureLog();
            seeder.SeedAsync().Wait();
            if (Convert.ToBoolean(Configuration["UseHttps"], System.Globalization.CultureInfo.InvariantCulture))
            {
                app.UseHttpsRedirection();
            }
            if (ConfigurationManager.UseSpa)
            {
                app.ConfigureSpa(ConfigurationManager.DistPath, ConfigurationManager.SpaNpmScript, ConfigurationManager.UseProxyToSpaDevelopmentServer, ConfigurationManager.DefaultSpaEndPoint);
            }
            app.UseMvc();
        }
        public void InsertData(DbContextOptions <DeviserDbContext> dbOption)
        {
            using var context = new DeviserDbContext(dbOption);
            var dataSeeder = new DataSeeder(context);

            dataSeeder.InsertData();
        }
Exemplo n.º 7
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.ApplyConfiguration(new UserConfiguration());
            modelBuilder.ApplyConfiguration(new UserRoomConfiguration());
            modelBuilder.ApplyConfiguration(new LocationConfiguration());
            modelBuilder.ApplyConfiguration(new RequestConfiguration());
            modelBuilder.ApplyConfiguration(new BookConfiguration());
            modelBuilder.ApplyConfiguration(new GenreConfiguration());
            modelBuilder.ApplyConfiguration(new BookGenreConfiguration());
            modelBuilder.ApplyConfiguration(new BookRatingConfiguration());
            modelBuilder.ApplyConfiguration(new AuthorConfiguration());
            modelBuilder.ApplyConfiguration(new BookAuthorConfiguration());
            modelBuilder.ApplyConfiguration(new RoleConfiguration());
            modelBuilder.ApplyConfiguration(new ResetPasswordConfiguration());
            modelBuilder.ApplyConfiguration(new ScheduleJobConfiguration());
            modelBuilder.ApplyConfiguration(new LanguageConfiguration());
            modelBuilder.ApplyConfiguration(new WishConfiguration());
            modelBuilder.ApplyConfiguration(new AphorismConfiguration());
            modelBuilder.ApplyConfiguration(new NotificationConfiguration());
            modelBuilder.ApplyConfiguration(new SuggestionMessageConfiguration());
            modelBuilder.ApplyConfiguration(new SettingConfiguration());
            modelBuilder.ApplyConfiguration(new IssueConfiguration());

            DataSeeder.Seed(modelBuilder);
        }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();



            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                var context  = services.GetRequiredService <CustomContext>();
                try
                {
                    DataSeeder.Initialize(services);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }

            host.Run();

            // CreateWebHostBuilder(args).Build().Run();
        }
Exemplo n.º 9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider, ApplicationDbContext db)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");
            });
            CreateRoles(serviceProvider, db).Wait();
            DataSeeder.SeedCountries(db);
        }
Exemplo n.º 10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseCors(builder => builder
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());

            //EasyEvent
            var easyEvents = app.ApplicationServices.GetService <IEasyEvents>();

            easyEvents.Configure(new EasyEventsConfiguration
            {
                Store          = new InMemoryEventStore(),
                HandlerFactory = type => app.ApplicationServices.CreateScope().ServiceProvider.GetService(type)
            });

            easyEvents.ReplayAllEventsAsync().Wait();

            //DataSeeder
            using (var scope = app.ApplicationServices.CreateScope())
            {
                var context = scope.ServiceProvider.GetService <MoneyExchangeDbContext>();
                DataSeeder.SeedCurrencies(context);
            }

            app.UseMvc();
        }
Exemplo n.º 11
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    var context     = services.GetRequiredService <DataContext>();
                    var roleManager = services.GetRequiredService <RoleManager <Role> >();
                    var userManager = services.GetRequiredService <UserManager <ApplicationUser> >();
                    context.Database.Migrate();
                    var dataSeeder = new DataSeeder(context, roleManager, userManager);
                    dataSeeder.Initialize().Wait();
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }
            host.Run();
        }
Exemplo n.º 12
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            var version = Assembly.GetEntryAssembly().GetName().Version;
            var versionpackageBuilder = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);

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

            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", versionpackageBuilder);
            });

            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthorization();

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

            System.Threading.Tasks.Task.Run(async() =>
            {
                await DataSeeder.SeedDataAsync(app);
            });
        }
Exemplo n.º 13
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();
            // Initialize the database
            var scopeFactory = host.Services.GetRequiredService <IServiceScopeFactory>();

            using (var scope = scopeFactory.CreateScope())
            {
                var db  = scope.ServiceProvider.GetRequiredService <ShopContext>();
                var udb = scope.ServiceProvider.GetRequiredService <Grupp9WebbShopUserContext>();
                var ds  = scope.ServiceProvider.GetRequiredService <IShopDataService>();
                // Uncoment if you want to delete an existing database and start over.
                // db.Database.EnsureDeleted();
                if (db.Database.EnsureCreated())
                {
                    DataSeeder.SeedDatabaseFromCsv(db);
                    udb.Database.Migrate();
                    foreach (var prod in await ds.GetProductsAsync())
                    {
                        ds.SetProductStock(prod.Id, 10);
                    }
                }
            }


            host.Run();
        }
Exemplo n.º 14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseCors(x => x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
            }

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();
            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("./swagger/v1/swagger.json", "Marvel Api");
                c.RoutePrefix = string.Empty;
            });

            app.UseRouting();

            app.UseAuthorization();

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

            using (var serviceScope = app.ApplicationServices.CreateScope())
            {
                var context = serviceScope.ServiceProvider.GetService <DataContext>();
                DataSeeder.SeedData(context);
            }
        }
Exemplo n.º 15
0
        public virtual async Task <TenantDto> CreateAsync(TenantCreateDto input)
        {
            var tenant = await TenantManager.CreateAsync(input.Name);

            input.MapExtraPropertiesTo(tenant);

            await TenantRepository.InsertAsync(tenant);

            await CurrentUnitOfWork.SaveChangesAsync();

            await DistributedEventBus.PublishAsync(
                new TenantCreatedEto
            {
                Id         = tenant.Id,
                Name       = tenant.Name,
                Properties =
                {
                    { "AdminEmail",    input.AdminEmailAddress },
                    { "AdminPassword", input.AdminPassword     }
                }
            });

            using (CurrentTenant.Change(tenant.Id, tenant.Name))
            {
                //TODO: Handle database creation?
                // TODO: Seeder might be triggered via event handler.
                await DataSeeder.SeedAsync(
                    new DataSeedContext(tenant.Id)
                    .WithProperty("AdminEmail", input.AdminEmailAddress)
                    .WithProperty("AdminPassword", input.AdminPassword)
                    );
            }

            return(ObjectMapper.Map <Tenant, TenantDto>(tenant));
        }
Exemplo n.º 16
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "MDM Swagger Endpoint");
            });
            app.UseCors(builder => builder.AllowAnyOrigin());
            app.UseMvc(cfg =>
            {
                cfg.MapRoute("Default", "{controller}/{action}/{id?}",
                             new { Controller = "Home", Action = "Index" });
            });

            using (IServiceScope scope = app.ApplicationServices.CreateScope())
            {
                DataSeeder seeder = scope.ServiceProvider.GetService <DataSeeder>();
                seeder.Seed().Wait();

                IVoiceRms voiceRms = scope.ServiceProvider.GetService <IVoiceRms>();
                voiceRms.Listen();
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Inserts data into database.
        /// </summary>
        /// <param name="webHost"></param>
        /// <returns></returns>
        public static IWebHost SeedingData(this IWebHost webHost)
        {
            var serviceScope       = webHost.Services.CreateScope();
            var services           = serviceScope.ServiceProvider;
            var context            = services.GetService <DataContext>();
            var hostingEnvironment = services.GetService <Microsoft.AspNetCore.Hosting.IHostingEnvironment>();

            if (hostingEnvironment.EnvironmentName == "Development")
            {
                context.Database.BeginTransaction();

                try
                {
                    if (!context.Cities.Any())
                    {
                        DataSeeder.InitData(context);
                    }

                    context.Database.CommitTransaction();
                }
                catch (Exception)
                {
                    context.Database.RollbackTransaction();
                }
            }

            return(webHost);
        }
Exemplo n.º 18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                              DataAccessContext context, RoleManager <IdentityRole> roleManager, UserManager <BlogUser> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseStatusCodePagesWithReExecute("/Error/{0}");
                app.UseExceptionHandler("/Error");
            }
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();

            DataSeeder.Preseeder(context, roleManager, userManager).Wait();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Exemplo n.º 19
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                var usersDbContext        = services.GetRequiredService <UsersDbContext>();
                var usersDbSeedingOptions = services.GetRequiredService <IOptions <UsersDbSeedingConfiguration> >();

                var boardsDbContext        = services.GetRequiredService <BoardsDbContext>();
                var boardsDbSeedingOptions = services.GetRequiredService <IOptions <BoardsDbSeedingConfiguration> >();

                try
                {
                    await usersDbContext.Database.MigrateAsync();

                    await boardsDbContext.Database.MigrateAsync();

                    await DataSeeder.SeedUsersDbAsync(usersDbContext, usersDbSeedingOptions);

                    await DataSeeder.SeedBoardsDbAsync(boardsDbContext, boardsDbSeedingOptions);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while seeding the dbs.");
                    throw;
                }
            }

            await host.RunAsync();
        }
        public async void UpdatingProject_ShouldUpdateProjectInDb()
        {
            var db = UnitTestHelper.CreateInMemoryDb();

            await using (var context = db.CreateContext())
            {
                context.Projects.Add(DataSeeder.NewProject(3));
                await context.SaveChangesAsync();

                context.Projects.Should().HaveCount(1);

                var projectService = new ProjectService(context, UnitTestHelper.Mapper);
                var project        = DataSeeder.NewProject(3);
                project.Name = "updated project name";
                project.Code = "updated project code";
                await projectService.UpdateOrThrow(project);
            }

            await using (var context = db.CreateContext())
            {
                context.Projects.Should().HaveCount(1);
                context.Projects.Should().Contain(x =>
                                                  x.Name == "updated project name" &&
                                                  x.Code == "updated project code");
            }
        }
Exemplo n.º 21
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                using (var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
                {
                    // Insert data in database
                    DataSeeder.InitializeDepartments(scope.ServiceProvider);
                    DataSeeder.InitializeUsers(scope.ServiceProvider);
                    DataSeeder.InitializeMedicine(scope.ServiceProvider);

                    #region Not validated seed
                    //DataSeeder.InitializeExternalDrugstoreMedicines(scope.ServiceProvider);
                    //DataSeeder.InitializeExternalDrugstoreSoldMedicines(scope.ServiceProvider);
                    //DataSeeder.InitializePresciptions(scope.ServiceProvider);
                    #endregion
                }
            }

            loggerFactory.AddFile("Logs/drugstore-{Date}.txt", LogLevel.Warning);
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    "default",
                    "{controller}/{action}",
                    new { controller = "Account", action = "Redirect" }
                    );
            });
        }
Exemplo n.º 22
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext context, RoleManager <ApplicationRole> roleManager, UserManager <ApplicationUser> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseSession();
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            DataSeeder.Initialize(context, userManager, roleManager).Wait();
        }
Exemplo n.º 23
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeeder dataSeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            dataSeeder.SeedSuperUser();

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                //routes.MapRoute(
                //    name: "MyArea",
                //    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataSeeder seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                string swaggerJsonBasePath = string.IsNullOrWhiteSpace(c.RoutePrefix) ? "." : "..";
                c.SwaggerEndpoint($"{swaggerJsonBasePath}/swagger/v1/swagger.json", "My API V1");
                c.RoutePrefix   = "api";
                c.DocumentTitle = "CoreWebApiWithEntityFrameworkAndIdentityBaseSeed API";
                //foreach (var description in provider.ApiVersionDescriptions)
                //{
                //    options.SwaggerEndpoint($"{swaggerJsonBasePath}/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
                //}
            });

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

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

            seeder.SeedData();
        }
Exemplo n.º 25
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();
            await DataSeeder.Initialize(host);

            await host.RunAsync();
        }
Exemplo n.º 26
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.MigrateDatabase <ProductsContext>();
            app.MigrateDatabase <AuthContext>();
            DataSeeder.SeedAuthData(app);

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "Area",
                    pattern: "{area:exists}/{controller=Home}/{action=Home}");

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Home}");
            });
        }
Exemplo n.º 27
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              UserManager <IdentityUser> userManager,
                              RoleManager <IdentityRole> roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();

            DataSeeder.Seed(userManager, roleManager);

            app.UseGraphity();

            app.UseGraphiQl("/graphiql", "/api/graph");

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Exemplo n.º 28
0
        protected override void Seed(GoSport.Data.ApplicationDbContext context)
        {
            const string AdministratorUserName = "******";
            const string AdministratorPassword = "******";

            if (context.Roles.Any())
            {
                return;
            }

            var dataSeeder = new DataSeeder(context);

            dataSeeder.SeedRoles();
            dataSeeder.SeedCategories();
            dataSeeder.SeedAddresses();

            try
            {
                var userStore   = new UserStore <User>(context);
                var userManager = new UserManager <User>(userStore);
                var user        = new User {
                    UserName = AdministratorUserName, Email = AdministratorUserName, Address = new Address()
                    {
                    }, Name  = "Admin"
                };
                userManager.Create(user, AdministratorPassword);
                userManager.AddToRole(user.Id, "Admin");
            }
            catch (Exception e)
            {
            };

            context.SaveChanges();
        }
Exemplo n.º 29
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, PortalDbContext dbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
            DataSeeder.Initialize(dbContext);
        }
 protected override void Seed(QLXLT_Data.Data.XLTContext context)
 {
     //  This method will be called after migrating to the latest version.
     DataSeeder.Seed(context);
     //  You can use the DbSet<T>.AddOrUpdate() helper extension method
     //  to avoid creating duplicate seed data.
 }