Example #1
0
 // GET: api/Products/5
 public Product Get(int id)
 {
     var productRepository = new ProductRepository();
     Product product;
     if(id >0)
     {
         var products = productRepository.Retrieve();
         product = products.FirstOrDefault(p => p.ProductId == id);
     }
     else
     {
         product = productRepository.Create();
     }
     return product;
 }
Example #2
0
 // PUT: api/Products/5
 public void Put(int id, [FromBody]Product product)
 {
     var productRepository = new ProductRepository();
     var updateProduct = productRepository.Save(id, product);
 }
Example #3
0
 // GET: api/products?search
 public IQueryable<Product> Get(string search)
 {
     var productRepository = new ProductRepository();
     var products = productRepository.Retrieve();
     return products.Where(p => p.ProductCode.Contains(search)).AsQueryable();
 }
Example #4
0
 // GET: api/Products
 public IQueryable<Product> Get()
 {
     var productRepository = new ProductRepository();
     return productRepository.Retrieve().AsQueryable();
 }