/// <summary> /// adds an item to a cart /// </summary> /// <param name="id"></param> /// <param name="item"></param> /// <exception cref="InvalidOperationException">Thrown if cart is already closed</exception> /// <returns></returns> public async Task AddToCart(string id, CartItem item) { var db = _redisProvider.Database; var closed = bool.Parse(await db.HashGetAsync(CartKey(id), "Closed")); if (closed) { throw new InvalidOperationException("Cart has already been closed out"); } var key = CartKey(id); await db.HashSetAsync(key, item.AsHashEntries(CartItemKey(id, item.Isbn)).ToArray()); }