示例#1
0
        private void EnsureDbMigration(BorrowedGamesContext dbContext, ILogger <Startup> logger, int tentatives = 1)
        {
            logger.LogInformation($"Attempting to Migrate Database. Tentative: {tentatives}");
            int count = tentatives;

            try
            {
                dbContext.Database.Migrate();
            }
            catch (Exception ex)
            {
                Thread.Sleep(30000);
                count += 1;
                if (count > 5)
                {
                    throw ex;
                }
                EnsureDbMigration(dbContext, logger, count);
            }
        }
示例#2
0
 public UserRepository(BorrowedGamesContext context) : base(context)
 {
 }
示例#3
0
 public BaseRepository(BorrowedGamesContext context)
 {
     _context = context;
     dbSet    = context.Set <T>();
 }
示例#4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <Startup> logger, BorrowedGamesContext borrowedGamesContext)
        {
            EnsureDbMigration(borrowedGamesContext, logger);

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

            app.UseRouting();
            app.UseCors(c => c.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());

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

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

            app.UseSwagger(c =>
            {
                c.SerializeAsV2 = true;
            });

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Invillia API");
                c.RoutePrefix = string.Empty;
            });
        }
示例#5
0
 public BorrowedGameRepository(BorrowedGamesContext options) : base(options)
 {
 }
示例#6
0
 public UnityOfWork(BorrowedGamesContext dbContext)
 {
     _dbcontext = dbContext;
 }