Example #1
0
        public void Checkout(string email)
        {
            Guid  orderId = Guid.NewGuid();
            Order o       = new Order();

            o.Id          = orderId;
            o.MemberEmail = email;
            o.OrderDate   = DateTime.UtcNow;
            _repo.AddOrder(o);

            var cartId    = _cartsRepo.GetCartId(email);
            var cartItems = _cartItemsRepo.GetCartItems(cartId).ToList();

            foreach (CartItem cartItem in cartItems)
            {
                OrderItem orderItem = new OrderItem();
                orderItem.OrderId   = orderId;
                orderItem.ProductId = cartItem.ProductId;
                orderItem.Quantity  = cartItem.Quantity;
                _orderItemsRepo.AddOrderItem(orderItem);
                _cartItemsRepo.DeleteCartItem(cartItem);
            }
        }
Example #2
0
 public Guid GetCartId(string email)
 {
     return(_repo.GetCartId(email));
 }