Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; });

            services
            .AddAuthentication(options =>
            {
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(options =>
                          options.TokenValidationParameters = new TokenValidationParameters
            {
                ValidateIssuer           = false,
                ValidateAudience         = false,
                ValidateLifetime         = true,
                ValidateIssuerSigningKey = true,
                IssuerSigningKey         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("2r5u8x/A?D(G+KbPeShVkYp3s6v9y$B&"))
            });

            services.AddCors(options =>
            {
                options.AddPolicy("AllowAll",
                                  p => p.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials());
            });

            var autoMapper = new MapperConfiguration(cfg =>
            {
                ServicesMapperConfigurator.RegisterMappings(cfg);
                ApiMapperConfiguration.RegisterMappings(cfg);
            }).CreateMapper();

            services.AddOptions();
            var builder = new ContainerBuilder();

            builder.Populate(services);

            builder = RegisterDependencyInjectionTypes(builder);
            builder.RegisterInstance(autoMapper).As <IMapper>();

            AutoFacContainer = builder.Build();

            return(new AutofacServiceProvider(AutoFacContainer));
        }
        public static void AddEventDefinitionsEntityFrameworkServices(this IServiceCollection services, string connectionString)
        {
            var migrationsAssembly = typeof(DalContext).GetTypeInfo().Assembly.GetName().Name;

            services.AddDbContext <DalContext>(options =>
                                               options.UseNpgsql(connectionString, b => b.MigrationsAssembly(migrationsAssembly))
                                               );

            ApiMapperConfiguration.Configure();

            services.AddTransient <ICurrentDateTimeProvider, CurrentDateTimeProvider>();
            services.AddTransient <IEventListProvider, EventListProvider>();
            services.AddTransient <ISceneDetailsProvider, SceneDetailsProvider>();
            services.AddTransient <IPriceZoneListProvider, PriceZoneListProvider>();
        }
Пример #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddSingleton <IContextFactory, ContextFactory>();
            services.AddScoped <IProductsService, ProductsService>();

            var config = new MapperConfiguration(cfg =>
            {
                ApiMapperConfiguration.ConfigureMappings(cfg);
            });

            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);
        }
Пример #4
0
        public static void AddApiServices(this IServiceCollection services)
        {
            ApiMapperConfiguration.Configure();

            services.AddTransient <ICurrentTimeProvider, CurrentTimeProvider>();

            services.AddTransient <IEventListProvider, EventListProvider>();
            services.AddTransient <ISceneDetailsProvider, SceneDetailsProvider>();
            services.AddTransient <IPriceZoneListProvider, PriceZoneListProvider>();
            services.AddTransient <IReservationsService, ReservationsService>();

            services.AddTransient <IUserClientCrudService, UserClientCrudService>();
            services.AddTransient <IClientsOrdersProvider, ClientOrdersProvider>();
            services.AddTransient <IOrderTicketsService, OrderTicketsService>();
            services.AddTransient <IClientsOrderService, ClientsOrderService>();

            services.AddTransient <IPaymentTypesProvider, PaymentTypesProvider>();
            services.AddTransient <IOrderPaymentsService, OrderPaymentsService>();
            services.AddTransient <IDeliveryTypesProvider, DeliveryTypesProvider>();
            services.AddTransient <IOrderDeliveriesService, OrderDeliveriesService>();

            services.AddTransient <IOrderManagementService, OrderManagementService>();
        }
Пример #5
0
 public void RunBeforeAnyTests()
 {
     // We need to create all the mappings before any of the test are run
     // All maps are created in the ApiMapperConfiguration constructor.
     ApiMapperConfiguration mapps = new ApiMapperConfiguration();
 }
Пример #6
0
 public void RunBeforeAnyTests()
 {
     ApiMapperConfiguration apiMaps = new ApiMapperConfiguration();
 }