public async Task SearchProducts() { var dbContext = new SalesDbContext(); dbContext.Database.Log = s => Console.WriteLine(s); var uow = new SalesUow(dbContext) as ISalesUow; var businessObject = new SalesBusinessObject(uow) as ISalesBusinessObject; Int32? supplierID = null; Int32? categoryID = null; String productName = null; var query = await Task.Run(() => { return(businessObject.GetProductsDetails(supplierID, categoryID, productName)); }); foreach (var item in query.ToList()) { Console.Write("ID: {0},", item.ProductID); Console.Write("Name: {0},", item.ProductName); Console.Write("Supplier: {0},", item.SupplierID); Console.Write("Category: {0}", item.CategoryID); Console.WriteLine(); } }
public async Task CreateOrder() { var header = new Order(); header.CustomerID = "ANATR"; header.EmployeeID = 6; header.OrderDate = DateTime.Now; header.RequiredDate = DateTime.Now.AddDays(7); header.ShippedDate = null; header.ShipVia = 1; header.Freight = 25.0m; header.ShipName = "Bill Gates"; header.ShipAddress = "Redmon II"; header.ShipCity = "Washington"; header.ShipRegion = "West"; header.ShipPostalCode = "12345"; header.ShipCountry = "USA"; header.OrderSummaries = new Collection <OrderDetailSummary>() { new OrderDetailSummary { ProductID = 1, Quantity = 3, Discount = 0.0m }, new OrderDetailSummary { ProductID = 10, Quantity = 2, Discount = 0.0m }, new OrderDetailSummary { ProductID = 20, Quantity = 1, Discount = 0.0m }, new OrderDetailSummary { ProductID = 30, Quantity = 1, Discount = 0.0m } }; var dbContext = new SalesDbContext(); dbContext.Database.Log = s => Console.WriteLine(s); var uow = new SalesUow(dbContext) as ISalesUow; var businessObject = new SalesBusinessObject(uow) as ISalesBusinessObject; var entity = await Task.Run(() => { return(businessObject.CreateOrder(header)); }); Console.WriteLine("Order #: {0}", entity.OrderID); businessObject.Release(); }