public static void CreateNewOder(int id_Custumer) { Oder oder = new Oder(); Method.ReadOnMember(); int pos_Custumer = Management.FindIndexOfIdCustumer(id_Custumer); if (pos_Custumer != -1) { if (Method.data.custumers[pos_Custumer].oders.Count == 0) { oder.OrderItem = 1; } else { int max = Method.data.custumers[pos_Custumer].oders[0].OrderItem; for (int i = 1; i < Method.data.custumers[pos_Custumer].oders.Count; i++) { if (Method.data.custumers[pos_Custumer].oders[i].OrderItem > max) { max = Method.data.custumers[pos_Custumer].oders[i].OrderItem; } } oder.OrderItem = max + 1; } oder.status = "Waiting"; oder.OrderId = int.Parse($"{id_Custumer}{ oder.OrderItem}"); string key = "Y"; do { Product product = new Product(); Console.WriteLine("Product list in store"); Management.ShowProduct(); Console.Write("\nEnter the Code to select the product: "); string code = Console.ReadLine(); int pos = Management.Find(code); while (pos == -1) { Console.Write("\nNot found! Enter again the Code to select the product: "); code = Console.ReadLine(); pos = Management.Find(code); } product.code_product = code; product.name_product = management.listProduct[pos].name_product; product.price_product = management.listProduct[pos].price_product; product.quantity_product = Management.CreateInteger("quantity", 1, 10000); int j; if (oder.products.Count == 0) { oder.products.Add(product); } else { for (j = 0; j < oder.products.Count; j++) { if (oder.products[j].code_product == product.code_product) { oder.products[j].quantity_product += product.quantity_product; break; } } if (j == oder.products.Count) { oder.products.Add(product); } } Console.Write("Continue? (Y/N): "); key = Console.ReadLine(); }while (key.ToUpper() != "N"); Method.data.custumers[pos_Custumer].oders.Add(oder); Method.PushInDATA(); } }