コード例 #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            var serviceScope = serviceProvider.CreateScope();

            using (BankingDBContext context = serviceScope.ServiceProvider.GetRequiredService <BankingDBContext>())
            {
                try
                {
                    context.Database.Migrate();
                }
                catch (Exception ex)
                {
                }

                if (!context.Accounts.Any())
                {
                    context.Accounts.Add(new Account
                    {
                        AccountType    = "Calculation",
                        AccountBalance = 1000
                    });

                    context.Accounts.Add(new Account
                    {
                        AccountType    = "Translation",
                        AccountBalance = 1000
                    });

                    context.SaveChanges();
                }
            }
        }
コード例 #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, BankingDBContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }


            app.UseHttpsRedirection();

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Banking Microservices api V1");
            });

            new Seed(context).SeedAsync().Wait();
            app.UseMvc();
        }
コード例 #3
0
 public AccountRepository(BankingDBContext context)
 {
     _context = context;
 }
コード例 #4
0
 public AccountRepository(BankingDBContext ctx)
 {
     _ctx = ctx;
 }
コード例 #5
0
 public AccountRepository(BankingDBContext bankingDBContext)
 {
     _bankingDBContext = bankingDBContext;
 }
コード例 #6
0
 public AccountRepository(BankingDBContext dbContext)
 {
     this._ctx = dbContext;
 }
コード例 #7
0
ファイル: Seed.cs プロジェクト: Vikas-Kumar56/MicroRabbitMQ
 public Seed(BankingDBContext bankingDBContext)
 {
     this.bankingDBContext = bankingDBContext;
 }