public string GetProductName(int productID) { using (var products = new ProductsContext()) { return(products.Products.FirstOrDefault(x => x.ProductID == productID)?.ProductName); } }
public int?GetProductQty(int productID) { using (var products = new ProductsContext()) { return(products.Products.FirstOrDefault(x => x.ProductID == productID)?.UnitInStock); } }
public int?GetCategoryID(int productID) { using (var products = new ProductsContext()) { return(products.Products.FirstOrDefault(x => x.ProductID == productID)?.CategoryID); } }
public void AddNewProduct() { using (var products = new ProductsContext()) { products.Products.Add(new Product() { ProductID = 1, ProductName = "C# 6 with Visual Studio", CategoryID = 2, CategoryName = "books", UnitInStock = 100 }); products.SaveChanges(); } }