|
|
|
@ -10,9 +10,9 @@ namespace Microsoft.eShopWeb.Infrastructure.Data |
|
|
|
public class CatalogContextSeed |
|
|
|
{ |
|
|
|
public static async Task SeedAsync(CatalogContext catalogContext, |
|
|
|
ILoggerFactory loggerFactory, int? retry = 0) |
|
|
|
ILoggerFactory loggerFactory, int retry = 0) |
|
|
|
{ |
|
|
|
int retryForAvailability = retry.Value; |
|
|
|
var retryForAvailability = retry; |
|
|
|
try |
|
|
|
{ |
|
|
|
if (catalogContext.Database.IsSqlServer()) |
|
|
|
@ -46,56 +46,55 @@ namespace Microsoft.eShopWeb.Infrastructure.Data |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
if (retryForAvailability < 10) |
|
|
|
{ |
|
|
|
if (retryForAvailability >= 10) throw; |
|
|
|
|
|
|
|
retryForAvailability++; |
|
|
|
var log = loggerFactory.CreateLogger<CatalogContextSeed>(); |
|
|
|
log.LogError(ex.Message); |
|
|
|
await SeedAsync(catalogContext, loggerFactory, retryForAvailability); |
|
|
|
} |
|
|
|
throw; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static IEnumerable<CatalogBrand> GetPreconfiguredCatalogBrands() |
|
|
|
{ |
|
|
|
return new List<CatalogBrand>() |
|
|
|
return new List<CatalogBrand> |
|
|
|
{ |
|
|
|
new CatalogBrand("Azure"), |
|
|
|
new CatalogBrand(".NET"), |
|
|
|
new CatalogBrand("Visual Studio"), |
|
|
|
new CatalogBrand("SQL Server"), |
|
|
|
new CatalogBrand("Other") |
|
|
|
new("Azure"), |
|
|
|
new(".NET"), |
|
|
|
new("Visual Studio"), |
|
|
|
new("SQL Server"), |
|
|
|
new("Other") |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
static IEnumerable<CatalogType> GetPreconfiguredCatalogTypes() |
|
|
|
{ |
|
|
|
return new List<CatalogType>() |
|
|
|
return new List<CatalogType> |
|
|
|
{ |
|
|
|
new CatalogType("Mug"), |
|
|
|
new CatalogType("T-Shirt"), |
|
|
|
new CatalogType("Sheet"), |
|
|
|
new CatalogType("USB Memory Stick") |
|
|
|
new("Mug"), |
|
|
|
new("T-Shirt"), |
|
|
|
new("Sheet"), |
|
|
|
new("USB Memory Stick") |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
static IEnumerable<CatalogItem> GetPreconfiguredItems() |
|
|
|
{ |
|
|
|
return new List<CatalogItem>() |
|
|
|
return new List<CatalogItem> |
|
|
|
{ |
|
|
|
new CatalogItem(2,2, ".NET Bot Black Sweatshirt", ".NET Bot Black Sweatshirt", 19.5M, "http://catalogbaseurltobereplaced/images/products/1.png"), |
|
|
|
new CatalogItem(1,2, ".NET Black & White Mug", ".NET Black & White Mug", 8.50M, "http://catalogbaseurltobereplaced/images/products/2.png"), |
|
|
|
new CatalogItem(2,5, "Prism White T-Shirt", "Prism White T-Shirt", 12, "http://catalogbaseurltobereplaced/images/products/3.png"), |
|
|
|
new CatalogItem(2,2, ".NET Foundation Sweatshirt", ".NET Foundation Sweatshirt", 12, "http://catalogbaseurltobereplaced/images/products/4.png"), |
|
|
|
new CatalogItem(3,5, "Roslyn Red Sheet", "Roslyn Red Sheet", 8.5M, "http://catalogbaseurltobereplaced/images/products/5.png"), |
|
|
|
new CatalogItem(2,2, ".NET Blue Sweatshirt", ".NET Blue Sweatshirt", 12, "http://catalogbaseurltobereplaced/images/products/6.png"), |
|
|
|
new CatalogItem(2,5, "Roslyn Red T-Shirt", "Roslyn Red T-Shirt", 12, "http://catalogbaseurltobereplaced/images/products/7.png"), |
|
|
|
new CatalogItem(2,5, "Kudu Purple Sweatshirt", "Kudu Purple Sweatshirt", 8.5M, "http://catalogbaseurltobereplaced/images/products/8.png"), |
|
|
|
new CatalogItem(1,5, "Cup<T> White Mug", "Cup<T> White Mug", 12, "http://catalogbaseurltobereplaced/images/products/9.png"), |
|
|
|
new CatalogItem(3,2, ".NET Foundation Sheet", ".NET Foundation Sheet", 12, "http://catalogbaseurltobereplaced/images/products/10.png"), |
|
|
|
new CatalogItem(3,2, "Cup<T> Sheet", "Cup<T> Sheet", 8.5M, "http://catalogbaseurltobereplaced/images/products/11.png"), |
|
|
|
new CatalogItem(2,5, "Prism White TShirt", "Prism White TShirt", 12, "http://catalogbaseurltobereplaced/images/products/12.png") |
|
|
|
new(2,2, ".NET Bot Black Sweatshirt", ".NET Bot Black Sweatshirt", 19.5M, "http://catalogbaseurltobereplaced/images/products/1.png"), |
|
|
|
new(1,2, ".NET Black & White Mug", ".NET Black & White Mug", 8.50M, "http://catalogbaseurltobereplaced/images/products/2.png"), |
|
|
|
new(2,5, "Prism White T-Shirt", "Prism White T-Shirt", 12, "http://catalogbaseurltobereplaced/images/products/3.png"), |
|
|
|
new(2,2, ".NET Foundation Sweatshirt", ".NET Foundation Sweatshirt", 12, "http://catalogbaseurltobereplaced/images/products/4.png"), |
|
|
|
new(3,5, "Roslyn Red Sheet", "Roslyn Red Sheet", 8.5M, "http://catalogbaseurltobereplaced/images/products/5.png"), |
|
|
|
new(2,2, ".NET Blue Sweatshirt", ".NET Blue Sweatshirt", 12, "http://catalogbaseurltobereplaced/images/products/6.png"), |
|
|
|
new(2,5, "Roslyn Red T-Shirt", "Roslyn Red T-Shirt", 12, "http://catalogbaseurltobereplaced/images/products/7.png"), |
|
|
|
new(2,5, "Kudu Purple Sweatshirt", "Kudu Purple Sweatshirt", 8.5M, "http://catalogbaseurltobereplaced/images/products/8.png"), |
|
|
|
new(1,5, "Cup<T> White Mug", "Cup<T> White Mug", 12, "http://catalogbaseurltobereplaced/images/products/9.png"), |
|
|
|
new(3,2, ".NET Foundation Sheet", ".NET Foundation Sheet", 12, "http://catalogbaseurltobereplaced/images/products/10.png"), |
|
|
|
new(3,2, "Cup<T> Sheet", "Cup<T> Sheet", 8.5M, "http://catalogbaseurltobereplaced/images/products/11.png"), |
|
|
|
new(2,5, "Prism White TShirt", "Prism White TShirt", 12, "http://catalogbaseurltobereplaced/images/products/12.png") |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|