//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>(); if (InputTitle != null && InputDifficulty == null && InputRating == null) { UserList = (ORM.RecipeAttempts.Where(x => x.Recipe.Title.ToLower().Contains(InputTitle.ToLower())).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")); }
//Get and display a list of distinct recipes public ActionResult DisplayAllAttempts() { RecipeDBEntities ORM = new RecipeDBEntities(); ContingencyCookingDAL DAL = new ContingencyCookingDAL(); List <RecipeAttempt> UserList = ORM.RecipeAttempts.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")); }
//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")); }