public ActionResult CreateNewOrder() { IOrderRepository orderRepo = new DbOrderRepository(); CreateNewOrderViewModel orders = orderRepo.GetData(); return(View(orders)); }
//Load ALL DATA from the database in their own lists using Dapper public CreateNewOrderViewModel GetData() { CreateNewOrderViewModel AllData = new CreateNewOrderViewModel(); AllData.Customers = db.Query <Customer>("SELECT * FROM dbo.Customer").ToList(); AllData.CustomerOrders = db.Query <CustomerOrder>("SELECT * FROM dbo.CustomerOrder").ToList(); AllData.OrderProduct = db.Query <OrderProduct>("SELECT * FROM dbo.OrderProduct").ToList(); AllData.Product = db.Query <Product>("SELECT * FROM dbo.Product").ToList(); return(AllData); }