public static void Seed(PandaDbContex context)
        {
            if (!context.Roles.Any())
            {
                context.Roles.Add(new PandaUserRole {
                    Name = "Admin", NormalizedName = "ADMIN"
                });
                context.Roles.Add(new PandaUserRole {
                    Name = "User", NormalizedName = "USER"
                });
            }

            if (!context.Statuses.Any())
            {
                context.Statuses.Add(new PackageStatus {
                    Name = "Pending"
                });
                context.Statuses.Add(new PackageStatus {
                    Name = "Shipped"
                });
                context.Statuses.Add(new PackageStatus {
                    Name = "Delivered"
                });
                context.Statuses.Add(new PackageStatus {
                    Name = "Acquired"
                });
            }

            context.SaveChanges();
        }
Exemple #2
0
 public void Configure(IServerRoutingTable serverRoutingTable)
 {
     using (var context = new PandaDbContex())
     {
         context.Database.EnsureCreated();
     }
 }
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            using (var contex = new PandaDbContex())
            {
                contex.Database.EnsureCreated();

                DbInitializer.Seed(contex);
            }


            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            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.UseDeveloperExceptionPage();



            app.UseAuthentication();
            app.UseMvcWithDefaultRoute();
        }
 public PackageServices(PandaDbContex contex, IUserServices userServices, Random random)
 {
     this.contex       = contex;
     this.userServices = userServices;
     this.random       = random;
 }
 public UserServices(PandaDbContex contex)
 {
     this.contex = contex;
 }
Exemple #6
0
 public PackagesService(PandaDbContex db, IReceiptService receiptService)
 {
     this.db             = db;
     this.receiptService = receiptService;
 }
 public UsersService(PandaDbContex db)
 {
     this.db = db;
 }
 public ReceiptServices(PandaDbContex contex, IPackageServices packageServices)
 {
     this.contex          = contex;
     this.packageServices = packageServices;
 }
 public ReceiptService(PandaDbContex db)
 {
     this.db = db;
 }