private static void PopulateData(MusicStoreContext context)
        {
            var genres = Enumerable.Range(1, 10).Select(n => new Genre());

            context.AddRange(genres);
            context.SaveChanges();
        }
示例#2
0
        private Task<List<Album>> GetTopSellingAlbumsAsync(MusicStoreContext dbContext, int count)
        {
            // Group the order details by album and return
            // the albums with the highest count

            return dbContext.Albums
                .OrderByDescending(a => a.OrderDetails.Count)
                .Take(count)
                .ToListAsync();
        }
示例#3
0
        private async Task<List<Album>> GetTopSellingAlbumsAsync(MusicStoreContext dbContext, int count)
        {
            // Group the order details by album and return
            // the albums with the highest count

            // TODO [EF] We don't query related data as yet, so the OrderByDescending isn't doing anything
            return await dbContext.Albums
                .OrderByDescending(a => a.OrderDetails.Count())
                .Take(count)
                .ToListAsync();
        }
        private static void PopulateData(MusicStoreContext context, string cartId, string albumTitle, int itemCount)
        {
            var album = new Album()
            {
                AlbumId = 1,
                Title = albumTitle,
            };

            var cartItems = Enumerable.Range(1, itemCount).Select(n =>
                new CartItem()
                {
                    AlbumId = 1,
                    Album = album,
                    Count = 1,
                    CartId = cartId,
                }).ToArray();

            context.AddRange(cartItems);
            context.SaveChanges();
        }
示例#5
0
 public ShoppingCart(MusicStoreContext db)
 {
     _db = db;
 }
示例#6
0
 public HomeController(MusicStoreContext context)
 {
     db = context;
 }
 public static ShoppingCart GetCart(MusicStoreContext db, HttpContext context)
 => GetCart(db, GetCartId(context));
示例#8
0
 public static ShoppingCart GetCart(MusicStoreContext db, HttpContext context)
 {
     var cart = new ShoppingCart(db);
     cart.ShoppingCartId = cart.GetCartId(context);
     return cart;
 }
 public GenresApiController(MusicStoreContext storeContext)
 {
     _storeContext = storeContext;
 }
示例#10
0
 public static ShoppingCart GetCart(MusicStoreContext db, string cartId)
     => new ShoppingCart(db, cartId);
 public StoreManagerController(MusicStoreContext dbContext, IOptions<AppSettings> options)
 {
     DbContext = dbContext;
     _appSettings = options.Value;
 }
示例#12
0
 public CheckoutController(MusicStoreContext context)
 {
     db = context;
 }
 public CartSummaryComponent(MusicStoreContext dbContext)
 {
     DbContext = dbContext;
 }
 public AnnouncementComponent(MusicStoreContext dbContext, IMemoryCache cache, ISystemClock clock)
 {
     DbContext = dbContext;
     Cache = cache;
     Clock = clock;
 }
示例#15
0
 public CartSummaryComponent(MusicStoreContext context)
 {
     db = context;
 }
 public ShoppingCartController(MusicStoreContext context)
 {
     db = context;
 }
示例#17
0
 public static ShoppingCart GetCart(MusicStoreContext db, HttpContext context) 
     => GetCart(db, GetCartId(context));
示例#18
0
 public ShoppingCart(MusicStoreContext dbContext)
 {
     _dbContext = dbContext;
 }
 public StoreManagerController(MusicStoreContext context)
 {
     db = context;
 }
 public GenreMenuComponent(MusicStoreContext dbContext)
 {
     DbContext = dbContext;
 }
示例#21
0
 public ShoppingCart(MusicStoreContext db)
 {
     _db = db;
 }
示例#22
0
 public StoreManagerController(MusicStoreContext dbContext)
 {
     DbContext = dbContext;
 }
 public ShoppingCartController(MusicStoreContext dbContext)
 {
     DbContext = dbContext;
 }
 public ShoppingCartController(MusicStoreContext dbContext, ILogger<ShoppingCartController> logger)
 {
     DbContext = dbContext;
     _logger = logger;
 }
示例#25
0
 private ShoppingCart(MusicStoreContext dbContext, string id)
 {
     _dbContext      = dbContext;
     _shoppingCartId = id;
 }
 public ShoppingCart(MusicStoreContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#27
0
 public static ShoppingCart GetCart(MusicStoreContext db, string cartId)
 => new ShoppingCart(db, cartId);
示例#28
0
 public static ShoppingCart GetCart(MusicStoreContext dbContext, string shoppingCartId)
 {
     return(new ShoppingCart(dbContext, shoppingCartId));
 }
 public ArtistsApiController(MusicStoreContext storeContext)
 {
     _storeContext = storeContext;
 }
示例#30
0
 private ShoppingCart(MusicStoreContext dbContext, string id)
 {
     _dbContext = dbContext;
     _shoppingCartId = id;
 }
 public AlbumsApiController(MusicStoreContext storeContext)
 {
     _storeContext = storeContext;
 }
 public GenreMenuComponent(MusicStoreContext context)
 {
     db = context;
 }