public void ShowShoppingCart() { Console.WriteLine("\t\t\tCart Items:" + user.GetShoppingCart().Count); int id = 1; Console.WriteLine("ItemId\tQty\tPrice\tTotalPrice\tName\t\t\t "); Console.WriteLine("-----------------------------------------------------------------"); Console.ResetColor(); double totalAmt = 0; List <Book> AllCartItems = user.GetShoppingCart(); foreach (Book cart in AllCartItems) { totalAmt += cart.GetQty() * cart.GetPrice(); if (Convert.ToInt32(cart.GetPrice()) == 0) { Console.WriteLine("" + id + "\t" + cart.GetQty() + "\t" + "Free" + "\t" + cart.GetQty() * cart.GetPrice() + "\t\t" + cart.GetName()); } else { Console.WriteLine("" + id + "\t" + cart.GetQty() + "\t" + cart.GetPrice() + "\t" + cart.GetQty() * cart.GetPrice() + "\t\t" + cart.GetName()); } Console.WriteLine("-----------------------------------------------------------------"); Console.ResetColor(); id++; } Console.WriteLine("\t TOTAL AMOUNT : " + totalAmt + "\t\t\t\t\t"); Console.WriteLine("-----------------------------------------------------------------"); Console.Write("Enter ItemId to edit the Cart Item or "); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("'Press 0 to go back on main menu'"); Console.ResetColor(); int itemId = Convert.ToInt32(Console.ReadLine()); if (itemId == 0) { Console.Clear(); ShowMenu(); SelectOption(); } else { List <Book> cartItems = user.GetShoppingCart(); int idx = itemId; Book item = cartItems[--idx]; Console.WriteLine("ItemId\tQty\tPrice\tTotalPrice\tName\t\t\t "); Console.WriteLine("-----------------------------------------------------------------"); if (Convert.ToInt32(item.GetPrice()) == 0) { Console.WriteLine("" + itemId + "\t" + item.GetQty() + "\t" + "Free" + "\t" + "Free" + "\t\t" + item.GetName()); } else { Console.WriteLine("" + itemId + "\t" + item.GetQty() + "\t" + item.GetPrice() + "\t" + item.GetQty() * item.GetPrice() + "\t\t" + item.GetName()); } Console.WriteLine("-----------------------------------------------------------------"); int newQty = 0; Console.WriteLine("To remove item enter new qty to 0"); Console.Write("Enter New Qty : "); newQty = Convert.ToInt32(Console.ReadLine()); if (AllCartItems.Any(x => x.GetName() == item.GetName())) { if (newQty == 0) { AllCartItems.Remove(item); } else { AllCartItems.FirstOrDefault(x => x.GetName() == item.GetName()).SetQty(newQty); } Console.Clear(); ShowMenu(); ShowShoppingCart(); } } }