static async Task Main(string[] args) { // adding the service reference in visual studio // generated a client class as well as a class for the data // we are sending on some of the operations (FridgeItem) using (var client = new KitchenServiceClient()) { var newItem = new FridgeItem { Name = "fried plantains", ExpirationDate = new DateTime(2020, 5, 1) }; client.PutInFridge(newItem); var items = await client.LookInsideFridgeAsync(); Console.WriteLine($"{items.Length} items:"); foreach (FridgeItem item in items) { Console.WriteLine($"{item.Name}, expires {item.ExpirationDate}"); } Console.ReadLine(); // pause before exiting } }
static void Main(string[] args) { Console.WriteLine("Welcome to your smart kitchen"); using (var client = new KitchenServiceClient()) { Console.WriteLine("opening fridge:"); var items = client.LookInsideFridge(); foreach (FridgeItem item in items) { Console.WriteLine($"{item.Name}, expires {item.Expiration.ToShortDateString()}"); } var result = client.CleanFridge(); Console.WriteLine($"fridge needed cleaning: {result}"); var items2 = client.LookInsideFridge(); Console.WriteLine("opening fridge:"); foreach (FridgeItem item in items2) { Console.WriteLine($"{item.Name}, expires {item.Expiration.ToShortDateString()}"); } } Console.ReadKey(); }