/// <summary> /// takes the current cart items and creates a cart view model /// </summary> /// <returns></returns> public CartViewModel GetCartViewModel() { CartViewModel cart = new CartViewModel(); double totalPrice = cart.GetTotalPrice(); foreach (var item in currentCartProducts) { string ProductName = item.productName; switch (ProductName) { case "Guitar": cart.guitar = "Guitar"; cart.guitarQty += 1; totalPrice += cart.GuitarPrice; break; case "Case": cart.Case = "Case"; cart.CaseQty += 1; totalPrice += cart.CasePrice; break; case "Strings": cart.strings = "Strings"; cart.stringsQty += 1; totalPrice += cart.stringPrice; break; case "Amplifier": cart.amplifier = "amplifier"; cart.amplifierQty += 1; totalPrice += cart.amplifierPrice; break; } } cart.totalPrice = totalPrice; return(cart); }