Ejemplo n.º 1
0
        // 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);
        }
Ejemplo n.º 2
0
 // PUT api/<controller>/5
 public void Put([FromBody] WebStoreData.Models.Product value)
 {
     WebStoreData.Repository.ProductRepository productRepository = new ProductRepository();
     productRepository.Edit(value);
 }
Ejemplo n.º 3
0
 // POST api/<controller>
 public bool Post([FromBody] WebStoreData.Models.Product value)
 {
     WebStoreData.Repository.ProductRepository productRepository = new ProductRepository();
     productRepository.Create(value);
     return(true);
 }