Beispiel #1
0
 //=========== create new product from class Product from application classes
 public static product create(Product product)
 {
     using(var res = new recipeEntities()){
         product p = new product();
         List<int> managers = res.users.Where(u => u.user_or_manager == true)
         .Select(u => u.id).ToList();
       p.name = product.name;
       p.description = product.description;
       p.user_id = product.userId;
       p.approved = managers.Any(id => id == p.user_id);
       p.amount_weight_in_volume = product.weight_in_volume;
       p.nutritional_per = product.nutritional_per;
       return p;
     }
 }
Beispiel #2
0
 public JsonResult product(product p)
 {
     using (recipes = new recipeEntities())
     {
         bool ans = false;
         if (ModelState.IsValid)
         {
             //recipes.Entry(p).State = EntityState.Modified;
             recipes.SaveChanges();
             ans = true;
         }
         return Json(new { success = ans, product = p }, JsonRequestBehavior.AllowGet);
     }
 }