コード例 #1
0
 public ShoppingCartCheckoutDTO GetCurrentCheckoutInfo(string username)
 {
     using (var context = new eBikesContext())
     {
         //THIS IS CRASHING WHEN THERE ARE NO ITEMS IN A CART NEED SOME CHECKING HERE
         ShoppingCartCheckoutDTO result = (from x in context.ShoppingCarts
                                           where x.OnlineCustomer.UserName.Equals(username)
                                           select new ShoppingCartCheckoutDTO
         {
             SubTotal = x.ShoppingCartItems.Sum(y => y.Quantity * y.Part.SellingPrice),
             Total = x.ShoppingCartItems.Sum(y => y.Quantity * y.Part.SellingPrice),
             ShoppingCartItems = (from y in x.ShoppingCartItems
                                  orderby y.Part.Description
                                  select new ShoppingCartLineItemPOCO
             {
                 Description = y.Part.Description,
                 Qty = y.Quantity,
                 UnitPrice = y.Part.SellingPrice,
                 ItemTotal = y.Quantity * y.Part.SellingPrice,
                 ShoppingCartItemId = y.ShoppingCartItemID
             }).ToList()
         }).FirstOrDefault();
         return(result);
     }
 }
コード例 #2
0
        public Task <bool> CheckoutShoppingCartAsync(ShoppingCartCheckoutDTO value)
        {
            throw new NotImplementedException();

            // validate shopping cart
            // create Order
            // remove shopping cart
        }
コード例 #3
0
 public async Task Checkout([FromBody] ShoppingCartCheckoutDTO value)
 {
     await _shoppingCartService.CheckoutShoppingCartAsync(value);
 }