예제 #1
0
        // GET: Heroes
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Index(string sortOrder, string searchString)
        {
            int lang    = LanguageBL.CheckLanguageSession();
            var heroesT = db.SPP_HeroesTransDistinct(lang).ToList();

            ViewBag.NameSortParam = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            if (!String.IsNullOrEmpty((searchString)))
            {
                heroesT = heroesT.Where(s => s.nameHero.ToLower().StartsWith(searchString.ToLower())).ToList();
            }
            switch (sortOrder)
            {
            case "name_desc":
                heroesT = heroesT.OrderByDescending(d => d.nameHero).ToList();
                break;

            default:
                heroesT = heroesT.OrderBy(d => d.nameHero).ToList();
                break;
            }

            return(View(heroesT));
        }