示例#1
0
        public async Task <ActionResult> Sets(int?page)
        {
            var schema = await db.GetSchemaAsync();

            List <ItemSetViewModel> itemSets = new List <ItemSetViewModel>();

            foreach (var itemSet in schema.ItemSets)
            {
                var itemSetViewModel = new ItemSetViewModel()
                {
                    Name  = await db.GetItemsLocalizationTextAsync(itemSet.Name.Remove(0, 1)),
                    Items = itemSet.Items.ToList().AsReadOnly()
                };

                itemSets.Add(itemSetViewModel);
            }

            return(View(itemSets.AsReadOnly()));
        }
示例#2
0
        public async Task <ActionResult> Index()
        {
            HomeViewModel viewModel = new HomeViewModel();

            IReadOnlyDictionary <uint, LeagueModel> leagues = null;

            try
            {
                leagues = await db.GetLeaguesAsync();
            }
            catch (HttpRequestException) { } // maybe log this in the future, for now do nothing
            viewModel.LeagueCount = leagues != null ? (int?)leagues.Count : null;

            var gameItems = await db.GetGameItemsAsync();

            var schema = await db.GetSchemaAsync();

            var heroes = await db.GetHeroDetailsAsync();

            var heroAbilities = await db.GetHeroAbilitiesAsync();

            viewModel.HeroCount        = heroes.Count;
            viewModel.HeroAbilityCount = heroAbilities.Count;
            viewModel.ShopItemCount    = schema.Items.Count;
            viewModel.InGameItemCount  = gameItems.Count;

            int?liveLeagueGameCount = null;

            try
            {
                liveLeagueGameCount = await db.GetLiveLeagueGameCountAsync();
            }
            catch (HttpRequestException)
            {
                // live league game endpoints return 500 or 404 randomly and without warning
                // maybe log this in the future, for now do nothing
            }
            viewModel.LiveLeagueGameCount = liveLeagueGameCount;

            var playerCounts = await db.GetPlayerCountsAsync();

            viewModel.InGamePlayerCount      = playerCounts.InGamePlayerCount;
            viewModel.DailyPeakPlayerCount   = playerCounts.DailyPeakPlayerCount;
            viewModel.AllTimePeakPlayerCount = playerCounts.AllTimePeakPlayerCount;

            LiveLeagueGameOverviewViewModel topLiveLeagueGame = null;

            try
            {
                topLiveLeagueGame = await GetTopLiveLeagueGameAsync();
            }
            catch (HttpRequestException)
            {
                // live league game endpoints return 500 or 404 randomly and without warning
                // maybe log this in the future, for now do nothing
            }
            viewModel.TopLiveLeagueGame = topLiveLeagueGame;

            viewModel.RandomHero = GetRandomHeroViewModel(heroes);
            await SetupRandomItems(viewModel, gameItems);

            var dotaBlogFeedItems = db.GetDotaBlogFeedItemsAsync();

            viewModel.DotaBlogFeedItems = AutoMapperConfiguration.Mapper.Map <
                IReadOnlyCollection <DotaBlogFeedItem>,
                IReadOnlyCollection <DotaBlogFeedItemViewModel> >
                                              (dotaBlogFeedItems);

            return(View(viewModel));
        }