private ShoppingCart CreateSessionCart(IDictionary<string, object> session)
 {
     var cart = new ShoppingCart();
     _db.ShoppingCarts.Add(cart);
     _db.SaveChanges();
     session[CART_SESSION_KEY] = cart.Id;
     return cart;
 }
 private ShoppingCart CreateUserCart(User user)
 {
     var cart = new ShoppingCart
     {
         User = user
     };
     _db.ShoppingCarts.Add(cart);
     _db.SaveChanges();
     return cart;
 }
        private ShoppingCart MigrateCart(int? shoppingCartId, User user)
        {
            if (!shoppingCartId.HasValue)
            {
                return null;
            }

            var cart = _db.ShoppingCarts.FirstOrDefault(c=>c.Id == shoppingCartId);

            if (cart == null)
            {
                return null;
            }
            var newCart = new ShoppingCart
            {
                User = user
            };
            newCart.ReplaceItems(cart.Items);

            return newCart;
        }