public void GetOrderFromUser(IEnumerable <MenuItems> menuItems) { int tableId = Utility.GetInputForTable(); while (!(tableId >= _MinimumNumberOfTables && tableId <= _MaximumNumberOfTables)) { Console.WriteLine("Please enter Table Number between {0} to {1}.", _MinimumNumberOfTables, _MaximumNumberOfTables); tableId = Utility.GetInputForTable(); } int itemId = Utility.GetInputForItem(); while (!(itemId >= _MinimumNumberOfItem && itemId <= menuItems.Count())) { Console.WriteLine("Please enter valid Item ID."); itemId = Utility.GetInputForItem(); } int quantity = Utility.GetInputForQuantity(); while (quantity < _MinimumQuantityToOrder) { Console.WriteLine("Quantity should be greater than 0."); quantity = Utility.GetInputForQuantity(); } var orderDetails = this._order.GetOrderDetails(); var tableDetails = orderDetails.Where(cd => cd.TableId == tableId); int count = 0; bool flag = true; foreach (var details in tableDetails) { if (details.ItemId == itemId) { quantity = quantity + details.Quanity; this._order.UpdateOrder(tableId, itemId, quantity, count); flag = false; break; } count++; } if (flag == true) { this._order.AddOrder(tableId, itemId, quantity); } var bill = _bill.GetBillDetails(); if (!(bill.Any(cd => cd.TableId == tableId))) { this._bill.AddBill(tableId, EnumPaymentStatus.Unpaid.ToString(), 0); } }