Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddDbContext <DoenerOrderContext>(options =>
            {
                options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"));
            });
            services.AddDbContext <AppIdentityDbContext>(options =>
            {
                options.UseNpgsql(Configuration.GetConnectionString("IdentityConnection"));
            });

            IdentitySetup.ConfigureService(services);
            JwtSetup.ConfigureService(services, Configuration);
            SwaggerSetup.ConfigureService(services);

            services.AddMediatR(typeof(CreateSupplierCommand).Assembly);
            services.AddValidatorsFromAssembly(typeof(CreateSupplierCommand).Assembly);
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(ValidationBehavior <,>));

            ServiceSetup.ConfigureService(services);

            services.AddCors(options =>
                             options.AddPolicy("AllowAll", builder => { builder.WithOrigins("*").AllowAnyMethod(); })
                             );
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DoenerOrderContext dbContext, AppIdentityDbContext appIdentityDbContext)
        {
            dbContext.Database.Migrate();
            appIdentityDbContext.Database.Migrate();

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

            app.UseHttpsRedirection();
            app.UseRouting();

            JwtSetup.ConfigureApplication(app);
            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }
Esempio n. 3
0
 public UserService(PostgresContext dbConn, JwtSetup setup)
 {
     _dbConn = dbConn;
     _setup  = setup;
 }
 public ControllerServices(PostgresContext dbContext, JwtSetup setup)
 {
     UserService = new UserService(dbContext, setup);
 }