コード例 #1
0
        public static void EnsureSeeded(this MusicStoreDbContext context)
        {
            var artists = SampleData.Artists;
            var genres  = SampleData.Genres;
            var albums  = SampleData.GetAlbums(genres, artists);

            //Ensure we have some status
            if (!context.Genres.Any())
            {
                context.AddRange(genres);
                context.SaveChanges();
            }
            //Ensure we create initial Threat List
            if (!context.Artists.Any())
            {
                context.AddRange(artists);
                context.SaveChanges();
            }

            if (!context.Albums.Any())
            {
                context.AddRange(albums);
                context.SaveChanges();
            }
        }
コード例 #2
0
 public static ShoppingCart GetCart(MusicStoreDbContext context, HttpContext httpContext)
 {
     return(new ShoppingCart(context, GetCartId(httpContext)));
 }
コード例 #3
0
 private ShoppingCart(MusicStoreDbContext context, string shoppingCartId)
 {
     _context        = context;
     _shoppingCartId = shoppingCartId;
 }