Exemple #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(); })
                             );
        }
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddDbContext <PlantLogBookContext>(options =>
            {
                options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"));
            });

            SwaggerSetup.ConfigureService(services);

            services.AddMediatR(typeof(CreatePlantSpeciesCommand).Assembly);
            services.AddValidatorsFromAssembly(typeof(CreatePlantSpeciesCommand).Assembly);
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(ValidationBehavior <,>));
            services.AddCors(options =>
                             options.AddPolicy("AllowAll", builder =>
            {
                builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
            })
                             );
        }