private ShoppingCart(IShoppingCart shoppingCart, IMusicStore musicStore, IOrderProcessing orderProcessing, string id) { _shoppingCart = shoppingCart; _musicStore = musicStore; _orderProcessing = orderProcessing; _shoppingCartId = id; }
// // GET: /Home/ public async Task <IActionResult> Index( [FromServices] IMusicStore musicStore, [FromServices] IMemoryCache cache) { // Get most popular albums var cacheKey = "topselling"; List <Album> albums; if (!cache.TryGetValue(cacheKey, out albums)) { albums = await musicStore.GetTopSellingAlbumsAsync(6); if (albums != null && albums.Count > 0) { if (_appSettings.CacheDbResults) { // Refresh it every 10 minutes. // Let this be the last item to be removed by cache if cache GC kicks in. cache.Set( cacheKey, albums, new MemoryCacheEntryOptions() .SetAbsoluteExpiration(TimeSpan.FromMinutes(10)) .SetPriority(CacheItemPriority.High)); } } } return(View(albums)); }
public GetAlbum( IHystrixCommandOptions options, IMusicStore storeService, IMemoryCache cache, IOptions <AppSettings> appsettings, ILogger <GetAlbum> logger ) : base(options) { _storeService = storeService; _cache = cache; _appSettings = appsettings.Value; _logger = logger; this.IsFallbackUserDefined = true; }
public async Task <IActionResult> AddressAndPayment( [FromServices] IMusicStore musicStore, [FromServices] IOrderProcessing orders, [FromServices] IShoppingCart shoppingCart, [FromForm] Order order, CancellationToken requestAborted) { if (!ModelState.IsValid) { return(View(order)); } var formCollection = await HttpContext.Request.ReadFormAsync(); try { if (string.Equals(formCollection["PromoCode"].FirstOrDefault(), PromoCode, StringComparison.OrdinalIgnoreCase) == false) { return(View(order)); } else { order.Username = HttpContext.User.Identity.Name; order.OrderDate = DateTime.Now; //Process the order var cart = ShoppingCart.GetCart(shoppingCart, musicStore, orders, HttpContext); int orderId = await cart.CreateOrderAsync(order); _logger.LogInformation("User {userName} started checkout of {orderId}.", order.Username, order.OrderId); return(RedirectToAction("Complete", new { id = orderId })); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); //Invalid - redisplay with errors return(View(order)); } }
public StoreManagerController(IMusicStore musicStore, IOptions <AppSettings> options) { MusicStoreService = musicStore; _appSettings = options.Value; }
public ShoppingCartController(IShoppingCart shoppingCart, IMusicStore musicStore, ILogger <ShoppingCartController> logger) { ShoppingCartService = shoppingCart; MusicStoreService = musicStore; _logger = logger; }
public CartSummaryComponent(IShoppingCart shoppingCart, IMusicStore musicStore) { ShoppingCartService = shoppingCart; MusicStoreService = musicStore; }
public StoreController(IMusicStore musicStore, IOptions <AppSettings> options) { MusicStore = musicStore; _appSettings = options.Value; }
public static ShoppingCart GetCart(IShoppingCart shoppingCart, IMusicStore musicStore, IOrderProcessing orderProcessing, string cartId) => new ShoppingCart(shoppingCart, musicStore, orderProcessing, cartId);
public static ShoppingCart GetCart(IShoppingCart shoppingCart, IMusicStore musicStore, IOrderProcessing orderProcessing, HttpContext context) => GetCart(shoppingCart, musicStore, orderProcessing, GetCartIdAsync(shoppingCart, context).Result);
public MusicLibrary(IMusicStore store) { _store = store; AllMusicPlayList=new PlayList(this); }
public GenreMenuComponent(IMusicStore musicStore) { MusicStore = musicStore; }