public void AddOrder(string name, List<Item> items) { Customer user = new Customer(name); user.Orders.Add(new Order(items)); Customers.Add(user); }
public void AddOrder(Customer who, List<Item> items) { int index = Customers.FindIndex(x => x.Id == who.Id); if (index != -1) { Customer user = Customers.ElementAt(index); user.Orders.Add(new Order(items)); Customers.Insert(index, user); } else { who.Orders.Add(new Order(items)); Customers.Add(who); } }