예제 #1
0
 // 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;
 }
예제 #2
0
 // PUT: api/Products/5
 public void Put(int id, [FromBody]ProductEntity product)
 {
     var productRepository = new ProductRepository();
     var updatedProduct = productRepository.Save(product);
 }
예제 #3
0
 // POST: api/Products
 public void Post([FromBody]ProductEntity product)
 {
     var productRepository = new ProductRepository();
     var newProduct = productRepository.Save(product);
 }
예제 #4
0
 public IQueryable<ProductEntity> Get()
 {
     var productRepository = new ProductRepository();
     return productRepository.RetrieveTable().AsQueryable();
 }
예제 #5
0
 // 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));
 }