Kaynağa Gözat

Remove functions from controller that are no longer used

Lee Morgan 6 yıl önce
ebeveyn
işleme
91d1d0fe69
2 değiştirilmiş dosya ile 0 ekleme ve 78 silme
  1. 0 75
      controllers/home.js
  2. 0 3
      routes.js

+ 0 - 75
controllers/home.js

@@ -135,54 +135,6 @@ module.exports = {
             });
     },
 
-    updateIngredient: (req, res)=>{
-        Merchant.findOne({cloverId: merchantId})
-            .then((merchant)=>{
-                for(let item of merchant.inventory){
-                    if(req.body.id === item.ingredient.toString()){
-                        item.quantity = req.body.quantity;
-                        break;
-                    }
-                }
-                merchant.save()
-                    .then((updatedMerchant)=>{
-                        return res.json(updatedMerchant);
-                    })
-                    .catch((err)=>{
-                        console.log(err);
-                        return res.json(err);
-                    })
-            })
-            .catch((err)=>{
-                console.log(err);
-                return res.render("error");
-            });
-    },
-
-    removeIngredient: (req, res)=>{
-        Merchant.findOne({cloverId: merchantId})
-            .then((merchant)=>{
-                for(let i = 0; i < merchant.inventory.length; i++){
-                    if(req.body.id === merchant.inventory[i].ingredient.toString()){
-                        merchant.inventory.splice(i, 1);
-                    }
-                }
-
-                merchant.save()
-                    .then((merchant)=>{
-                        return res.json(merchant);
-                    })
-                    .catch((err)=>{
-                        console.log(err);
-                        return res.json(err);
-                    });
-            })
-            .catch((err)=>{
-                console.log(err);
-                return res.json(err);
-            });
-    },
-
     createIngredient: (req, res)=>{
         Ingredient.create(req.body.ingredient)
             .then((ingredient)=>{
@@ -245,33 +197,6 @@ module.exports = {
             });
     },
 
-    updateRecipeIngredient: function(req, res){
-        Recipe.findOne({_id: req.body.recipeId})
-            .populate("ingredients.id")
-            .then((recipe)=>{
-                for(let i = 0; i < recipe.ingredients.length; i++){
-                    if(recipe.ingredients[i]._id.toString() === req.body.ingredient._id){
-                        recipe.ingredients.splice(i, 1);
-                        recipe.ingredients.push(req.body.ingredient);
-                        break;
-                    }
-                }
-
-                recipe.save()
-                    .then((recipe)=>{
-                        return res.json(recipe);
-                    })
-                    .catch((err)=>{
-                        console.log(err);
-                        return res.render("error");
-                    })
-            })
-            .catch((err)=>{
-                console.log(err);
-                res.render("error");
-            });
-    },
-
     updateMerchant: function(req, res){
         Merchant.updateOne({_id: req.body._id}, req.body)
             .then((merchant)=>{

+ 0 - 3
routes.js

@@ -7,10 +7,7 @@ module.exports = function(app){
     app.post("/merchant/create", home.createMerchant);
     app.post("/merchant/update", home.updateMerchant);
     app.post("/ingredients/create", home.createNewIngredients);
-    // app.post("/ingredients/update", home.updateIngredient);
-    // app.post("/ingredients/remove", home.removeIngredient);
     app.post("/ingredients/createone", home.createIngredient);
     app.get("/recipes", home.displayRecipes);
     app.post("/recipes/ingredients/remove", home.deleteRecipeIngredient);
-    // app.post("/recipes/ingredients/update", home.updateRecipeIngredient);
 }