Ejemplo n.º 1
0
        public ActionResult Dashboard()
        {
            List <Recipe> favouritedRecipeList = new List <Recipe>();
            List <Recipe> myRecipeList         = new List <Recipe>();

            //load from home recipe list
            //List<Recipe> recipeList = HomeController.recipeList;

            //load from database recipe list
            SqlConnect recipeLoader = new SqlConnect();

            recipeLoader.retriveData("select * from Recipe");

            List <Recipe> recipeList = RecipeAccess.getInstance().getRecipeList(recipeLoader.sqlTable);

            foreach (Recipe recipe in recipeList)
            {
                if (recipe.isEditable)
                {
                    myRecipeList.Add(recipe);
                }
                if (recipe.isFavourited)
                {
                    favouritedRecipeList.Add(recipe);
                }
            }

            return(View(new UserDashboardModel(myRecipeList, favouritedRecipeList)));
        }
Ejemplo n.º 2
0
        //GET: home/index
        public ActionResult Index(string searchString)
        {
            SqlConnect recipeLoader = new SqlConnect();

            recipeLoader.retriveData("select * from Recipe");

            recipeList = RecipeAccess.getInstance().getRecipeList(recipeLoader.sqlTable);


            if (!String.IsNullOrEmpty(searchString))
            {
                switch (searchString.ToLower())
                {
                case "all":
                    break;

                case "food":
                    recipeList = recipeList.Where(s => s.type.Equals("food")).ToList();
                    break;

                case "drinks":
                    recipeList = recipeList.Where(s => s.type.Equals("drinks")).ToList();
                    break;

                default:
                    recipeList = recipeList.Where(s => s.name.ToLower().Contains(searchString.ToLower())).ToList <Recipe>();
                    break;
                }
            }

            return(View(recipeList));
        }