Example #1
0
 public IHttpActionResult GetProductById(int id)
 {
     using (var context = new DhoniEnterprisesEntities())
     {
         var result = (context.uspGetSingleProduct(id).AsEnumerable()).FirstOrDefault();
         de_server.Models.Product prod = new de_server.Models.Product(result.ProductId, result.ProductName, result.origin, result.quality, result.purity, result.moisture, result.splits, result.weaveled, result.damaged, result.foreignMatter, result.greenDamaged, result.otherColor, result.wrinkled);
         return(Ok(new { success = true, product = prod }));
     }
 }
Example #2
0
 public IHttpActionResult PostEditProduct([FromBody] JObject newProduct)
 {
     using (var context = new DhoniEnterprisesEntities())
     {
         int userID = BasicAuthHttpModule.getCurrentUserId();
         de_server.Models.Product product = newProduct["product"].ToObject <de_server.Models.Product>();
         if (userID != -1)
         {
             var result = context.uspAddProduct(product.name, Convert.ToInt32(userID), product.specs.moisture, product.specs.weeviled, product.origin, product.specs.purity, product.specs.splits, product.quality, product.specs.damaged, product.specs.foreignMatter, product.specs.greenDamaged, product.specs.otherColor, product.specs.wrinkled);
             return(Ok(new { success = true, message = "New Product Added!" }));
         }
         else
         {
             return(NotFound());
         }
     }
 }