static void Main(string[] args) { Console.WriteLine("Enter Cliente Data: "); Console.WriteLine("Name: "); string name = Console.ReadLine(); Console.WriteLine("Email: "); string email = Console.ReadLine(); Console.WriteLine("Birth date (DD/MM/YYYY): "); DateTime date = DateTime.Parse(Console.ReadLine()); Client c1 = new Client(name, email, date); Console.WriteLine("Enter order data: "); Console.WriteLine("Status: "); OrderStatus status = Enum.Parse <OrderStatus>(Console.ReadLine()); Order o1 = new Order(status, c1); Console.WriteLine("How many items to this order? "); int cont = int.Parse(Console.ReadLine()); for (int i = 1; i <= cont; i++) { Console.WriteLine($"Enter #{i} item data: "); Console.WriteLine("Product name: "); string productName = Console.ReadLine(); Console.WriteLine("Product price: "); double productPrice = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.WriteLine("Quantity: "); int productQuantity = int.Parse(Console.ReadLine()); Product p = new Product(productName, productPrice); OrderItem order = new OrderItem(productQuantity, p); o1.AddItem(order); } Console.WriteLine(o1.ToString()); }
static void Main(string[] args) { Console.WriteLine("Enter client data:"); Console.Write("Name: "); string clientName = Console.ReadLine(); Console.Write("Email: "); string clientEmail = Console.ReadLine(); Console.Write("Birth date (DD/MM/YYYY): "); DateTime clientBirth = DateTime.Parse(Console.ReadLine()); Client client = new Client(clientName, clientEmail, clientBirth); Console.WriteLine("Enter order data:"); Console.Write("Status: "); OrderStatus orderStatus = Enum.Parse <OrderStatus>(Console.ReadLine()); Order order = new Order(DateTime.Now, orderStatus, client); Console.Write("How many items to this order? "); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { Console.WriteLine($"Enter #{i+1} item data:"); Console.Write("Product name: "); string productName = Console.ReadLine(); Console.Write("Product price: "); double productPrice = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Quantity: "); int productQuantity = int.Parse(Console.ReadLine()); Product product = new Product(productName, productPrice); OrderItem item = new OrderItem(productQuantity, productPrice, product); order.AddItem(item); } Console.WriteLine(order); }
static void Main(string[] args) { OrderService os = new OrderService(); while (true) { int multifunc; Console.Write("1.Add order\n2.Remove order\n3.Search order by client name\n4.Add order detail\n5.Update orderdetail\n6.Remove order detail\nEnter function:"); Order resultorder = new Order(); bool selected = false; if (int.TryParse(Console.ReadLine(), out multifunc)) { switch (multifunc) { case 1: int addorderoid; Console.WriteLine("Enter order id"); if (int.TryParse(Console.ReadLine(), out addorderoid)) { Console.WriteLine("Enter client name"); os.AddOrder(addorderoid, Console.ReadLine()); } break; case 2: int removeorderoid; Console.WriteLine("Enter oid"); if (int.TryParse(Console.ReadLine(), out removeorderoid)) { os.RemoveOrder(removeorderoid); //Console.WriteLine("{0}", os.GetByCname("hi")[0]); } break; case 3: Console.WriteLine("Enter client name"); List <Order> clientnamesearchresult = os.GetByCname(Console.ReadLine()); Console.Write("Press number of order for further process"); int numchoose; if (int.TryParse(Console.ReadLine(), out numchoose)) { if (1 <= numchoose && numchoose <= clientnamesearchresult.Count) { resultorder = clientnamesearchresult[numchoose - 1]; selected = true; } } break; case 4: if (selected) { resultorder.AddItem(new OrderDetail(Console.ReadLine(), int.Parse(Console.ReadLine()))); } else { throw new Exception("No order is selected"); } break; case 5: if (selected) { resultorder.UpdateItem(Console.ReadLine(), int.Parse(Console.ReadLine())); } else { throw new Exception("No order is selected"); } break; case 6: if (selected) { resultorder.RemoveItem(Console.ReadLine()); } else { throw new Exception("No order is selected"); } break; } } else { break; } //Console.WriteLine(os.GetByCname("hi")[0].customername); //os.GetByCname("hi")[0].AddItem(new OrderDetail("apple", 2)); // os.GetByCname("hi")[0].Removeitem("apple"); //os.RemoveOrder(1); } //Console.ReadKey(); }