Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            ChampionsList champions = new ChampionsList();

            using (LOLWildRiftService service = new LOLWildRiftService())
            {
                champions = await service.ChampionList();
            }
            return(View());
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Index(string searchString)
        {
            ChampionsList champions = new ChampionsList();

            try
            {
                AlreadyLoggedIn();

                champions = await _services.ChampionList();

                if (!champions.Error)
                {
                    foreach (var data in champions.Champions)
                    {
                        if (data.HISTORY != null && data.HISTORY.Length > 10)
                        {
                            data.HISTORY = data.HISTORY.Substring(0, 50) + "...";
                        }
                    }

                    if (!String.IsNullOrEmpty(searchString))
                    {
                        @ViewData["CurrentFilter"] = searchString;
                        var resultObj = champions.Champions.Where(c => c.NAME.ToUpper().Contains(searchString.ToUpper()) ||
                                                                  c.LANE.ToUpper().Contains(searchString.ToUpper()) ||
                                                                  c.ROLE.ToUpper().Contains(searchString.ToUpper()));
                        return(View(resultObj.ToList()));
                    }
                }
                else
                {
                    return(RedirectToAction("ErrorPage"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("ErrorPage"));
            }
            return(View(champions.Champions));
        }