Exemplo n.º 1
0
 public IHttpActionResult Create([FromBody] ProductCustomViewModel dataBody)
 {
     try
     {
         using (var db = new DB_Context())
         {
             Product product = dataBody.ConvertToProduct();
             db.Products.Add(product);
             db.SaveChanges();
             return(Ok("Data Saved Successfully"));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 2
0
 public IHttpActionResult CustomCreateProduct([FromBody] ProductCustomViewModel dataBody)
 {
     try
     {
         using (var db = new DB_Context())
         {
             var temp = db.Products.AsQueryable();
             Dictionary <string, object> result = new Dictionary <string, object>();
             Product product = dataBody.ConvertToProduct();
             db.Products.Add(product);
             db.SaveChanges();
             return(Ok("Data Saved Successfully"));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }