public CustomerOrdersPresenter(ICustomerOrders customerOrdersView, OrderDetailsPresenter orderDetailsPresenter) { view = customerOrdersView; detailsPresenter = orderDetailsPresenter; view.OrderSelected += View_OrderSelected; view.OrderDeleted += View_OrderDeleted; using (var db = new everyloopNETContext()) { if (db.Database.CanConnect()) { var products = db.Products.OrderBy(p => p.ProductName).ToList(); detailsPresenter.LoadProducts(products); view.Customers = db.Customers .Include(customer => customer.Orders) .ThenInclude(order => order.OrderDetails) .ThenInclude(details => details.Product) .ToList(); } else { Debug.WriteLine("Connection failed!"); } } }
public Form1() { InitializeComponent(); var treeview = new CustomerOrdersTree() { Dock = DockStyle.Fill }; splitContainer1.Panel1.Controls.Add(treeview); var datagrid = new OrderDetailsGrid() { Dock = DockStyle.Fill }; splitContainer2.Panel2.Controls.Add(datagrid); var detailsPresenter = new OrderDetailsPresenter(datagrid); new CustomerOrdersPresenter(treeview, detailsPresenter); }