diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/Base/ViewModelLocator.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/Base/ViewModelLocator.cs index 22b8bc99d..8a6b6356a 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/Base/ViewModelLocator.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/Base/ViewModelLocator.cs @@ -42,7 +42,7 @@ namespace eShopOnContainers.Core.ViewModels.Base { _container = new TinyIoCContainer(); - // View models + // View models - by default, TinyIoC will register concrete classes as multi-instance. _container.Register(); _container.Register(); _container.Register(); @@ -54,21 +54,21 @@ namespace eShopOnContainers.Core.ViewModels.Base _container.Register(); _container.Register(); - // Services - _container.Register().AsSingleton(); + // Services - by default, TinyIoC will register interface registrations as singletons. + _container.Register(); _container.Register(); _container.Register(); _container.Register(); _container.Register(); _container.Register(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); + _container.Register(); + _container.Register(); + _container.Register(); + _container.Register(); + _container.Register(); + _container.Register(); + _container.Register(); + _container.Register(); } public static void UpdateDependencies(bool useMockServices) @@ -76,21 +76,21 @@ namespace eShopOnContainers.Core.ViewModels.Base // Change injected dependencies if (useMockServices) { - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); + _container.Register(); + _container.Register(); + _container.Register(); + _container.Register(); + _container.Register(); UseMockService = true; } else { - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); - _container.Register().AsSingleton(); + _container.Register(); + _container.Register(); + _container.Register(); + _container.Register(); + _container.Register(); UseMockService = false; } diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs index 42ac7b740..712719e23 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs @@ -30,7 +30,7 @@ if (!context.CatalogBrands.Any()) { - context.CatalogBrands.AddRange(useCustomizationData + await context.CatalogBrands.AddRangeAsync(useCustomizationData ? GetCatalogBrandsFromFile(contentRootPath, logger) : GetPreconfiguredCatalogBrands()); @@ -39,7 +39,7 @@ if (!context.CatalogTypes.Any()) { - context.CatalogTypes.AddRange(useCustomizationData + await context.CatalogTypes.AddRangeAsync(useCustomizationData ? GetCatalogTypesFromFile(contentRootPath, logger) : GetPreconfiguredCatalogTypes()); @@ -48,7 +48,7 @@ if (!context.CatalogItems.Any()) { - context.CatalogItems.AddRange(useCustomizationData + await context.CatalogItems.AddRangeAsync(useCustomizationData ? GetCatalogItemsFromFile(contentRootPath, context, logger) : GetPreconfiguredItems()); diff --git a/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs index 3dbf28171..058c58dbc 100644 --- a/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs @@ -33,7 +33,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data if (!context.Users.Any()) { - context.Users.AddRange(useCustomizationData + await context.Users.AddRangeAsync(useCustomizationData ? GetUsersFromFile(contentRootPath, logger) : GetDefaultUser()); diff --git a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs index b109bf896..db43c6019 100644 --- a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs @@ -27,17 +27,17 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data if (!await context.Clients.AnyAsync()) { - context.Clients.AddRange(Config.GetClients(clientUrls).Select(client => client.ToEntity())); + await context.Clients.AddRangeAsync(Config.GetClients(clientUrls).Select(client => client.ToEntity())); } if (!await context.IdentityResources.AnyAsync()) { - context.IdentityResources.AddRange(Config.GetResources().Select(resource => resource.ToEntity())); + await context.IdentityResources.AddRangeAsync(Config.GetResources().Select(resource => resource.ToEntity())); } if (!await context.ApiResources.AnyAsync()) { - context.ApiResources.AddRange(Config.GetApis().Select(api => api.ToEntity())); + await context.ApiResources.AddRangeAsync(Config.GetApis().Select(api => api.ToEntity())); } await context.SaveChangesAsync(); diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs index 6396d3f5d..c42b1975e 100644 --- a/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs +++ b/src/Services/Marketing/Marketing.API/Infrastructure/MarketingContextSeed.cs @@ -19,7 +19,7 @@ { if (!context.Campaigns.Any()) { - context.Campaigns.AddRange( + await context.Campaigns.AddRangeAsync( GetPreconfiguredMarketings()); await context.SaveChangesAsync(); diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs b/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs index 83c2b1ba2..d0dce865f 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs @@ -19,11 +19,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Autof builder.RegisterAssemblyTypes(typeof(IMediator).GetTypeInfo().Assembly) .AsImplementedInterfaces(); - // Register all the Command classes (they implement IAsyncRequestHandler) in assembly holding the Commands + // Register all the Command classes (they implement IRequestHandler) in assembly holding the Commands builder.RegisterAssemblyTypes(typeof(CreateOrderCommand).GetTypeInfo().Assembly) .AsClosedTypesOf(typeof(IRequestHandler<,>)); - // Register the DomainEventHandler classes (they implement IAsyncNotificationHandler<>) in assembly holding the Domain Events + // Register the DomainEventHandler classes (they implement INotificationHandler<>) in assembly holding the Domain Events builder.RegisterAssemblyTypes(typeof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler).GetTypeInfo().Assembly) .AsClosedTypesOf(typeof(INotificationHandler<>)); diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs index 53c53f052..4f3f0b0f2 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs @@ -39,7 +39,7 @@ if (!context.CardTypes.Any()) { - context.CardTypes.AddRange(useCustomizationData + await context.CardTypes.AddRangeAsync(useCustomizationData ? GetCardTypesFromFile(contentRootPath, logger) : GetPredefinedCardTypes()); @@ -48,7 +48,7 @@ if (!context.OrderStatus.Any()) { - context.OrderStatus.AddRange(useCustomizationData + await context.OrderStatus.AddRangeAsync(useCustomizationData ? GetOrderStatusFromFile(contentRootPath, logger) : GetPredefinedOrderStatus()); }