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); } }
public Task <bool> CheckoutShoppingCartAsync(ShoppingCartCheckoutDTO value) { throw new NotImplementedException(); // validate shopping cart // create Order // remove shopping cart }
public async Task Checkout([FromBody] ShoppingCartCheckoutDTO value) { await _shoppingCartService.CheckoutShoppingCartAsync(value); }