Exemplo n.º 1
0
        private void AddApplicationServices(IServiceCollection services)
        {
            var connectionString = this.Configuration["postgres-user"];
            var redisUrl         = this.Configuration["redis-url"];

            services.AddSingleton <DocumentClient>(x => {
                var options = x.GetService <IOptions <AzureAccountDetails> >();
                return(new DocumentClient(new Uri(options.Value.CosmosDbEndpoint), options.Value.CosmosDbKey, serializerSettings: new JsonSerializerSettings
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                }));
            });

            services.AddMediatR(typeof(Startup).Assembly);
            services.AddAutoMapper(typeof(Startup));
            services.AddDistributedRedisCache(opt => {
                opt.Configuration = redisUrl;
            });

            services.AddDomainServices();

            services.AddScoped <IDbConnection>(db => new NpgsqlConnection(connectionString));

            FluentMapper.Initialize(config => {
                EntityMaps.Initialize(config);
            });
        }
Exemplo n.º 2
0
        private void CacheEntityMappings(string entityType)
        {
            var entityMap = new StoreEntityMap()
            {
                StoreID = this.StoreID, EntityType = entityType
            };

            entityMap.MappedObjects = MappedObjectCollection.GetObjects(this.StoreID, entityType);

            EntityMaps.Add(entityMap);
        }
Exemplo n.º 3
0
        private void CacheEntityMappings()
        {
            EntityMaps.Clear();

            // cache per entity map
            CacheEntityMappings("Product");
            CacheEntityMappings("Manufacturer");
            CacheEntityMappings("Category");
            CacheEntityMappings("Section");
            CacheEntityMappings("Coupon");
            CacheEntityMappings("OrderOption");
            CacheEntityMappings("GiftCard");
            CacheEntityMappings("ShippingMethod");
            CacheEntityMappings("Affiliate");
            CacheEntityMappings("Topic");
            CacheEntityMappings("News");
        }
 protected override void OnModelCreating(DbModelBuilder modelBuilder) => EntityMaps.Configure(modelBuilder);