public IHttpActionResult Get(int id) { try { Product product; var pr = new ProductRepository(); if (id > 0) { var products = pr.Retrieve(); product = products.FirstOrDefault(p => p.ProductId == id); if (product == null) { return NotFound(); } } else { product = pr.Create(); } return Ok(product); } catch (Exception ex) { return InternalServerError(ex); } }
public IHttpActionResult Get() { try { var ps = new ProductRepository(); return Ok(ps.Retrieve() .AsQueryable()); } catch (Exception ex) { return InternalServerError(ex); } }