Browse Source

Making "any" async (#397)

* Making "any" async

* Removed unused using

Co-authored-by: Eric Fleming <eric-fleming18@hotmail.com>
main
yigith 6 years ago
committed by GitHub
parent
commit
623ec49ed7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/Infrastructure/Data/CatalogContextSeed.cs

11
src/Infrastructure/Data/CatalogContextSeed.cs

@ -1,8 +1,8 @@
using Microsoft.eShopWeb.ApplicationCore.Entities; using Microsoft.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Microsoft.eShopWeb.Infrastructure.Data namespace Microsoft.eShopWeb.Infrastructure.Data
@ -17,8 +17,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data
{ {
// TODO: Only run this if using a real database // TODO: Only run this if using a real database
// context.Database.Migrate(); // context.Database.Migrate();
if (!await catalogContext.CatalogBrands.AnyAsync())
if (!catalogContext.CatalogBrands.Any())
{ {
catalogContext.CatalogBrands.AddRange( catalogContext.CatalogBrands.AddRange(
GetPreconfiguredCatalogBrands()); GetPreconfiguredCatalogBrands());
@ -26,7 +25,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data
await catalogContext.SaveChangesAsync(); await catalogContext.SaveChangesAsync();
} }
if (!catalogContext.CatalogTypes.Any()) if (!await catalogContext.CatalogTypes.AnyAsync())
{ {
catalogContext.CatalogTypes.AddRange( catalogContext.CatalogTypes.AddRange(
GetPreconfiguredCatalogTypes()); GetPreconfiguredCatalogTypes());
@ -34,7 +33,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data
await catalogContext.SaveChangesAsync(); await catalogContext.SaveChangesAsync();
} }
if (!catalogContext.CatalogItems.Any()) if (!await catalogContext.CatalogItems.AnyAsync())
{ {
catalogContext.CatalogItems.AddRange( catalogContext.CatalogItems.AddRange(
GetPreconfiguredItems()); GetPreconfiguredItems());

Loading…
Cancel
Save