コード例 #1
0
        //
        public ActionResult ChooseDifficulty2(string RecipeID)
        {
            ContingencyCookingDAL DAL = new ContingencyCookingDAL();

            JObject JsonData = DAL.GetRecipeByID(RecipeID);

            if (Session["Recipe"] == null)
            {
                Session.Add("Recipe", JsonData);
            }
            else
            {
                Session["Recipe"] = JsonData;
            }

            ViewBag.RecipeName   = JsonData["Title"];
            ViewBag.RecipeID     = JsonData["RecipeID"];
            ViewBag.Cuisine      = JsonData["Cuisine"];
            ViewBag.Ingredients  = JsonData["Ingredients"]; //In view add .(whatever) to pull info and throw into for loop
            ViewBag.Instructions = JsonData["Instructions"];
            ViewBag.Photo        = JsonData["PhotoUrl"];

            //Goes through instructions, then removes ingredients from instructions
            List <string> ingString = new List <string>();

            foreach (var item in JsonData["Ingredients"])
            {
                ingString.AddRange(item["Name"].ToString().Split(' '));
            }

            string instString = JsonData["Instructions"].ToString();

            StringBuilder sb = new StringBuilder(instString);

            for (int i = 0; i < ingString.Count; i++)
            {
                if (!string.IsNullOrEmpty(ingString[i]))
                {
                    sb.Replace(ingString[i].ToLower(), "_____");

                    sb.Replace(ingString[i][0].ToString().ToUpper() + ingString[i].Substring(1), "_____");
                }
                //instString = instString.Replace(ingString[i], "____");
                //Regex.Replace(sb.ToString(), ingString[i], "____", RegexOptions.IgnoreCase);
            }

            ViewBag.stingsomething = ingString;

            ViewBag.finalInstructions = sb.ToString();

            return(View("Level2"));
        }
コード例 #2
0
        //View full-page spread of recipe but nothing else
        public ActionResult ViewRecipe(string RecipeID)
        {
            ContingencyCookingDAL DAL = new ContingencyCookingDAL();

            JObject JsonData = DAL.GetRecipeByID(RecipeID);

            ViewBag.RecipeName   = JsonData["Title"];
            ViewBag.RecipeID     = JsonData["RecipeID"];
            ViewBag.Cuisine      = JsonData["Cuisine"];
            ViewBag.Ingredients  = JsonData["Ingredients"]; //In view add .(whatever) to pull info and throw into for loop
            ViewBag.Instructions = JsonData["Instructions"];
            ViewBag.Photo        = JsonData["PhotoUrl"];

            return(View("SeeFullRecipe"));
        }
コード例 #3
0
        public ActionResult ChooseDifficulty3(string RecipeID)
        {
            ContingencyCookingDAL DAL = new ContingencyCookingDAL();

            JObject JsonData = DAL.GetRecipeByID(RecipeID);

            if (Session["Recipe"] == null)
            {
                Session.Add("Recipe", JsonData);
            }
            else
            {
                Session["Recipe"] = JsonData;
            }

            ViewBag.RecipeName   = JsonData["Title"];
            ViewBag.RecipeID     = JsonData["RecipeID"];
            ViewBag.Cuisine      = JsonData["Cuisine"];
            ViewBag.Ingredients  = JsonData["Ingredients"]; //In view add .(whatever) to pull info and throw into for loop
            ViewBag.Instructions = JsonData["Instructions"];
            ViewBag.Photo        = JsonData["PhotoUrl"];

            return(View("Level3"));
        }