Beispiel #1
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            // использование Fluent API
            base.OnModelCreating(modelBuilder);

            // Инициализация БД
            // /*
            List <Role> roles = InitDataBase.CreateRoles();
            List <User> users = new List <User> {
                InitDataBase.CreateUser(1), InitDataBase.CreateUser(2), InitDataBase.CreateUser(2), InitDataBase.CreateUser(3)
            };

            for (int i = 0; i < 15; i++)
            {
                users.Add(InitDataBase.CreateUser(3));
            }

            List <Category> categores = InitDataBase.CreateCategory();

            List <Room> rooms = new List <Room> {
                InitDataBase.CreateRoom(1), InitDataBase.CreateRoom(2), InitDataBase.CreateRoom(3)
            };

            for (int i = 0; i < 25; i++)
            {
                rooms.Add(InitDataBase.CreateRoom());
            }

            List <RoomCost> costs = InitDataBase.CreateRoomCost();

            List <Transaction> transctions = new List <Transaction>();

            for (int i = 0; i < 15; i++)
            {
                var trans = InitDataBase.CreateTransaction();
                if (transctions != null)
                {
                    transctions.Add(trans);
                }
            }

            modelBuilder.Entity <Role>().HasData(roles);
            modelBuilder.Entity <User>().HasData(users);
            modelBuilder.Entity <Category>().HasData(categores);
            modelBuilder.Entity <Room>().HasData(rooms);
            modelBuilder.Entity <RoomCost>().HasData(costs);
            modelBuilder.Entity <Transaction>().HasData(transctions);

            /*
             */
        }
Beispiel #2
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            await host.StartAsync();

            var context = ServiceProvider.GetRequiredService <ApplicationDatabaseContext>();

            InitDataBase.Seed(context);

            var mainWindow = host.Services.GetRequiredService <MainWindow>();

            mainWindow.Show();

            var navigationService = ServiceProvider.GetRequiredService <NavigationService>();

            navigationService.ShowPage(PageNameConstants.LoginPage);

            base.OnStartup(e);
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public static void Configure(IApplicationBuilder app)
        {
            app.UseDeveloperExceptionPage();
            InitDataBase.InitDB(app.ApplicationServices);
            var task = new Task(() => GameLoop.Init(app.ApplicationServices), TaskCreationOptions.LongRunning);

            task.Start();
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                // Mapping of endpoints goes here:
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";
                spa.UseReactDevelopmentServer(npmScript: "start");
            });
        }