//TODO: Add complexity to selection system
        //Search all attempts by title, difficulty, or rating
        public ActionResult SearchAllAttempts(string InputTitle, string InputDifficulty, string InputRating)
        {
            RecipeDBEntities      ORM      = new RecipeDBEntities();
            ContingencyCookingDAL DAL      = new ContingencyCookingDAL();
            List <RecipeAttempt>  UserList = new List <RecipeAttempt>();

            string[] splitInput = InputTitle.Split(' ');

            if (InputTitle != null && InputDifficulty == null && InputRating == null)
            {
                for (int i = 0; i < splitInput.Length; i++)
                {
                    if (InputTitle.Contains(splitInput[i]))
                    {
                        var temp = splitInput[i];
                        UserList = ORM.RecipeAttempts.Where(x => x.Recipe.Title.ToLower().Contains(temp.ToString())).ToList();
                    }
                }

                //UserList = (from p in ORM.RecipeAttempts where splitInput.Any(val => p.Recipe.Title.Contains(val)) select p).ToList();
            }
            else if (InputTitle == null && InputDifficulty != null && InputRating == null)
            {
                UserList = ORM.RecipeAttempts.Where(x => x.Difficulty.Contains(InputDifficulty)).ToList();
            }
            else if (InputTitle == null && InputDifficulty == null && InputRating != null)
            {
                UserList = ORM.RecipeAttempts.Where(x => x.Rating.ToString().Contains(InputRating)).ToList();
            }

            List <string> UserEmails = DAL.GetUserEmailsFromAttempts(UserList);

            ViewBag.Emails         = UserEmails;
            ViewBag.Results        = UserList;
            ViewBag.ListDifficulty = ORM.RecipeAttempts.Select(y => y.Difficulty).Distinct().ToList();
            ViewBag.ListRating     = ORM.RecipeAttempts.Select(y => y.Rating).Distinct().ToList();

            return(View("../Home/AllResults"));
        }
Beispiel #2
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"));
        }