Exemplo n.º 1
0
        public CheckoutViewModel GetCart(string cartId)
        {
            var cartItems = checkoutRepository.GetCart(cartId);

            //sums up the total cost
            var sum = cartItems.Select(c => c.Price * c.Quantity).Sum();

            //put all of the items and the total cost into a new view model
            var checkoutItems = new CheckoutViewModel();

            checkoutItems.Cart = cartItems;
            checkoutItems.Sum  = sum;

            return(checkoutItems);
        }