예제 #1
0
        public IActionResult Index(string criteria)
        {
            //update viewdata criteria
            switch (criteria)
            {
            case "Hanner":
                ViewData["SearchCriteria"] = criteria;
                break;

            case "Taever":
                ViewData["SearchCriteria"] = "Tæver";
                break;

            case "StoreHunde":
                ViewData["SearchCriteria"] = "Store Hunde";
                break;

            case "SmaeHunde":
                ViewData["SearchCriteria"] = "Små Hunde";
                break;

            case null:
                ViewData["SearchCriteria"] = "Alle Navne";
                break;
            }


            //get names
            List <string> names = new List <string>();

            if (criteria == "AlleNavne" || criteria == null)
            {
                names = _assets.GetAllNames();
            }
            else
            {
                names = _assets.GetNamesWithCriteria(criteria);
            }

            names.Sort();

            return(View(names));
        }