예제 #1
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AdmContext admContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseCors(_allowSpecificOrigins);
            try
            {
                Console.WriteLine("Trying to connect to database...");
                int retries = 1;
                while (retries < 7)
                {
                    try
                    {
                        Console.WriteLine("Connecting to database. Trial: {0}", retries);
                        admContext.Database.MigrateAsync().GetAwaiter().GetResult();
                        break;
                    }
                    catch
                    {
                        Thread.Sleep((int)Math.Pow(2, retries) * 1000);
                        retries++;
                    }
                }
                Console.WriteLine("Database connected successfully.");
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred when trying to connect to database. Error: {}.", e);
            }

            var optionsBuilder = new DbContextOptionsBuilder <AdmContext>();

            optionsBuilder.UseNpgsql(_admConnectionString);
            using (var context = new AdmContext(optionsBuilder.Options))
            {
                context.Database.Migrate();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseStaticFiles();

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

            app.UseGraphQLPlayground(new GraphQLPlaygroundOptions());
        }
예제 #2
0
 public LoginService(AdmContext context, WodinContext contextAplicacao)
 {
     _context          = context;
     _contextAplicacao = contextAplicacao;
 }
예제 #3
0
 public MenuService(AdmContext context)
 {
     _context = context;
 }
예제 #4
0
 public AdmEmpresasController(AdmContext context)
 {
     _context = context;
 }
예제 #5
0
 public UsuarioPermissaoAcessosController(WodinContext context, AdmContext admContext)
 {
     _context         = context;
     this._admContext = admContext;
 }
예제 #6
0
 public MenusController(AdmContext context, MenuService menuService)
 {
     _context     = context;
     _menuService = menuService;
 }
예제 #7
0
 public UserController(AdmContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #8
0
 public LoginsController(AdmContext context, WodinContext contextAplicacao, LoginService loginService)
 {
     _context          = context;
     _contextAplicacao = contextAplicacao;
     _loginService     = loginService;
 }
예제 #9
0
 public SubMenusController(AdmContext context, SubMenuService submenuService)
 {
     _context        = context;
     _submenuService = submenuService;
 }