public Domains.ShoppingCart Get(int userId)
        {
            if (!database.ContainsKey(userId))
            {
                database[userId] = new Domains.ShoppingCart(userId);
            }

            return(database[userId]);
        }
        public async Task Save(Domains.ShoppingCart shoppingCart)
        {
            using (var conn = await GetOpenConnectionAsync().ConfigureAwait(false))
                using (var tx = conn.BeginTransaction())
                {
                    // Deletes all preexisting shopping cart items
                    await conn.ExecuteAsync(deleteAllForShoppingCartSql, new { shoppingCart.UserId }, tx)
                    .ConfigureAwait(false);

                    // Deletes all preexisting shopping cart
                    await conn.ExecuteAsync(deleteShoppingCartForUserSql, new { shoppingCart.UserId }, tx)
                    .ConfigureAwait(false);

                    // Adds the current shopping cart
                    shoppingCart.Id = await conn
                                      .ExecuteScalarAsync <int>(addShoppingCartForUserSql, new { shoppingCart.UserId }, tx)
                                      .ConfigureAwait(false);

                    // Adds the current shopping cart items
                    await conn.ExecuteAsync(
                        addAllForShoppingCartSql,
                        shoppingCart.Items.Select(
                            i => new
                    {
                        ShoppingCartId = shoppingCart.Id,
                        i.ProductCatalogId,
                        i.ProductName,
                        i.Description,
                        i.Price.Currency,
                        i.Price.Amount
                    }
                            ),
                        tx
                        )
                    .ConfigureAwait(false);

                    tx.Commit();
                }
        }
 public void Save(Domains.ShoppingCart shoppingCart)
 {
     // Nothing needed. Saving would be needed with a real DB
 }