Esempio n. 1
0
        public void ConfigureServices(IServiceCollection services)
        {
            var servicesHelper = new ServicesHelper(services, Configuration);

            servicesHelper.ConfigureSettings();
            servicesHelper.ConfigureServices();
            servicesHelper.ConfigureRepositories();
            servicesHelper.ConfigureAuthServices();
            servicesHelper.ConfigureUtils();
            servicesHelper.ConfigureLogger();

            services.AddSpaStaticFiles(configuration =>
                                       { configuration.RootPath = "WebAppsBuild"; });

            services.AddDbContext <DatabaseContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <AddAuctionCommandValidator>());

            services.AddMediatR(typeof(AddAuctionCommand).GetTypeInfo().Assembly);

            services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "API", Version = "v1"
                });
            });


            servicesHelper.RunBackgroundServices();
        }