public void GetsAllOrdersForCustomer() { //Arrange var options = BuildInMemoryDb("GetsCustomersOrders"); //Act using (var context = new P0DbContext(options)) { CreateOneCustomer(context); CreateTwoproducts(context); var store = new Store { StoreId = 1, Location = "Location1" }; context.Add(store); context.SaveChanges(); var order = new Order { CusomerId = 1, OrderDateTime = DateTime.Now, OrderId = 1, StoreId = 1, }; context.Add(order); order = new Order { CusomerId = 1, OrderDateTime = DateTime.Now, OrderId = 2, StoreId = 1, }; context.Add(order); context.SaveChanges(); } //Assert using (var context = new P0DbContext(options)) { var backend = new StoreBackend(context); var orders = backend.GetCustomerOrderHistory(1); Assert.Equal(2, orders.Count); } }
private void DisplayOrderHistory() { Console.Clear(); var orders = db.GetCustomerOrderHistory(customer.CustomerId); if (orders == null || orders.Count == 0) { Console.WriteLine("You havent placed any orders yet."); } else { foreach (var order in orders) { var output = $"Order {order.OrderId} placed on {order.OrderDate.ToShortDateString()} at the {order.StoreLocation} location totalling {order.OrderTotal}"; Console.WriteLine(output); } } Console.Write("Press any key to return to the previous menu."); Console.ReadLine(); }