// GET api/<controller>/5 public string Get(int id) { WebStoreData.Repository.ProductRepository productRepository = new ProductRepository(); WebStoreData.Models.Product product = productRepository.GetProductById(id); string result = JsonConvert.SerializeObject(product, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(result); }
// PUT api/<controller>/5 public void Put([FromBody] WebStoreData.Models.Product value) { WebStoreData.Repository.ProductRepository productRepository = new ProductRepository(); productRepository.Edit(value); }
// POST api/<controller> public bool Post([FromBody] WebStoreData.Models.Product value) { WebStoreData.Repository.ProductRepository productRepository = new ProductRepository(); productRepository.Create(value); return(true); }