public decimal GetPrice(int productId) { DemoDBModel context = new DemoDBModel(); var product = context.Products.Find(productId); if (product == null) { throw new ArgumentOutOfRangeException("productId"); } return(product.Price); }
public Product GetProduct(int productId) { DemoDBModel context = new DemoDBModel(); var product = context.Products.Find(productId); if (product == null) { throw new ArgumentOutOfRangeException("productId"); } return(new Product { Id = product.Id, Name = product.Name, Price = product.Price }); }