Beispiel #1
0
        public ActionResult ShowAllDrinks(string str)
        {
            CategoryDrinkModel model = new CategoryDrinkModel();

            if (string.IsNullOrEmpty(str))
            {
                model.drinks          = db.drinks.ToList();
                model.currentCategory = "All Drinks";
                return(View(model));
            }
            if (str.Equals("All Drinks"))
            {
                model.drinks          = db.drinks.ToList();
                model.currentCategory = str;
                return(View(model));
            }
            else if (str.Equals("Alcoholic"))
            {
                model.drinks          = db.drinks.Where(p => p.Category.CategoryName.Equals("Alcoholic")).ToList();
                model.currentCategory = str;
                return(View(model));
            }
            else if (str.Equals("Non-Alcoholic"))
            {
                model.drinks          = db.drinks.Where(p => p.Category.CategoryName.Equals("Non-Alcoholic")).ToList();
                model.currentCategory = str;
                return(View(model));
            }

            return(View(model));
        }
Beispiel #2
0
        public ActionResult SearchOn(string str)
        {
            CategoryDrinkModel modelList = new CategoryDrinkModel();

            modelList.drinks          = db.drinks.Where(d => str == null || d.Name.StartsWith(str)).ToList();
            modelList.currentCategory = "Mixed";
            return(View("ShowAllDrinks", modelList));
        }