コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: konstantinvelev/SoftUni
 public void Configure(IServerRoutingTable serverRoutingTable)
 {
     using (var context = new PandaDbContex())
     {
         context.Database.EnsureCreated();
     }
 }
コード例 #3
0
        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();
        }
コード例 #4
0
 public PackageServices(PandaDbContex contex, IUserServices userServices, Random random)
 {
     this.contex       = contex;
     this.userServices = userServices;
     this.random       = random;
 }
コード例 #5
0
 public UserServices(PandaDbContex contex)
 {
     this.contex = contex;
 }
コード例 #6
0
 public PackagesService(PandaDbContex db, IReceiptService receiptService)
 {
     this.db             = db;
     this.receiptService = receiptService;
 }
コード例 #7
0
 public UsersService(PandaDbContex db)
 {
     this.db = db;
 }
コード例 #8
0
 public ReceiptServices(PandaDbContex contex, IPackageServices packageServices)
 {
     this.contex          = contex;
     this.packageServices = packageServices;
 }
コード例 #9
0
 public ReceiptService(PandaDbContex db)
 {
     this.db = db;
 }