Example #1
0
        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);
        }
Example #2
0
        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
            });
        }