// GET: api/Products/5 public ProductEntity Get(int id) { ProductEntity product; var productRepository = new ProductRepository(); if (id > 0) { var products = productRepository.RetrieveTable(); product = products.FirstOrDefault(p => p.ProductId.Equals(id)); } else { product = productRepository.Create(); } return product; }
// PUT: api/Products/5 public void Put(int id, [FromBody]ProductEntity product) { var productRepository = new ProductRepository(); var updatedProduct = productRepository.Save(product); }
// POST: api/Products public void Post([FromBody]ProductEntity product) { var productRepository = new ProductRepository(); var newProduct = productRepository.Save(product); }
public IQueryable<ProductEntity> Get() { var productRepository = new ProductRepository(); return productRepository.RetrieveTable().AsQueryable(); }
// GET: api/Products/SearchQuery public IEnumerable<ProductEntity>Get(string search) { var productRepository = new ProductRepository(); var products = productRepository.RetrieveTable(); return products.Where(p => p.PartitionKey.Contains(search)); }