Exemple #1
0
 def Food(self, id):
     res = []
     food = FoodModel.findById(id)
     if food is None:
         return {'message': 'Food not found.'}, 404
     temp_food = food.to_dict()
     if temp_food:
         return temp_food
         res.append(temp_food)
     return {"result": res}
Exemple #2
0
    def put(self, id):
        data = Foods.parser.parse_args()
        food = FoodModel.findById(id)

        if food is None:
            return {'message': 'Food not found.'}
        else:
            food.name = data['name']
            food.money = data['money']
        food.saveToDb()
        return food.to_dict()
Exemple #3
0
 def delete(self, id):
     food = FoodModel.findById(id)
     if food:
         food.deleteFromDb()
         return {'message': 'Food deleted.'}
     return {'message': 'Food not found.'}, 404