コード例 #1
0
ファイル: WebUtils.cs プロジェクト: cbudo/SpeedyChef
        public static Recipe getRecipeViewInfo(int recId)
        {
            JsonValue recipeInfo = getJSONResponse ("/RecipeInfo/RecipeInfo?recid=" + recId);
            recipeInfo = recipeInfo [0];
            JsonValue recipeTasks = getJSONResponse ("/RecipeInfo/RecipeTasks?recid=" + recId);
            JsonValue recipeIngredients = getJSONResponse ("/RecipeInfo/RecipeIngredients?recid=" + recId);
            Recipe r = new Recipe ();
            r.title = recipeInfo ["Recname"];
            //r.desc = recipeInfo ["Recdesc"];
            //r.time = recipeInfo ["Rectime"];
            //r.diff = recipeInfo ["Recdiff"];
            string[] ingredients = new string[recipeIngredients.Count];
            string[] tasks = new string[recipeTasks.Count];
            for (int i = 0; i < recipeIngredients.Count; i++) {
                //ingredients [i] = "Ingredient " + i;
                string ingredient = recipeIngredients[i]["Foodname"];
                if (recipeIngredients [i] ["FoodAmount"] != null)
                    ingredient += ", " + recipeIngredients [i] ["FoodAmount"];
                if (recipeIngredients [i] ["FoodAmountUnit"] != null)
                    ingredient += " " + recipeIngredients [i] ["FoodAmountUnit"];

                ingredients [i] = ingredient;
            }

            int recTime = 0;
            for (int i = 0; i < recipeTasks.Count; i++) {
                tasks [i] = recipeTasks [i] ["Taskdesc"];
                recTime += recipeTasks [i] ["Tasktime"];
            }
            r.ingredients = ingredients;
            r.tasks = tasks;
            return r;
        }
コード例 #2
0
        public static Recipe getRecipeViewInfo(int recId)
        {
            JsonValue recipeInfo = getJSONResponse ("/RecipeInfo/RecipeInfo?recid=" + recId);
            recipeInfo = recipeInfo [0];
            JsonValue recipeTasks;
            JsonValue recipeIngredients;
            if (recId == 8) {
                if (CachedData.Instance.unitSystem == "U.S.") {
                    recipeTasks = tasks8_US;
                    recipeIngredients = ingredients8_US;
                } else {
                    recipeTasks = tasks8_M;
                    recipeIngredients = ingredients8_M;
                }
            } else {
                recipeTasks = getJSONResponse ("/RecipeInfo/RecipeTasks?recid=" + recId);
                recipeIngredients = getJSONResponse ("/RecipeInfo/RecipeIngredients?recid=" + recId);
            }

            Recipe r = new Recipe ();
            r.title = recipeInfo ["Recname"];
            //r.desc = recipeInfo ["Recdesc"];
            //r.time = recipeInfo ["Rectime"];
            //r.diff = recipeInfo ["Recdiff"];
            string[] ingredients = new string[recipeIngredients.Count];
            string[] tasks = new string[recipeTasks.Count];
            for (int i = 0; i < recipeIngredients.Count; i++) {
                ingredients [i] = recipeIngredients[i]["Foodname"];
            }

            int recTime = 0;
            for (int i = 0; i < recipeTasks.Count; i++) {
                tasks [i] = recipeTasks [i] ["Taskdesc"];
                recTime += recipeTasks [i] ["Tasktime"];
            }
            r.ingredients = ingredients;
            r.tasks = tasks;
            return r;
        }