示例#1
0
        public async Task <ActionResult> ThemeResults(Guid groupId, Guid themeId, int page = 1, int pageSize = 10)
        {
            var group = await _groupAdminService.GetGroupByIdAsync(groupId);

            var results = await _resultAdminService.GetResultsByGroupIdThemeIdAsync(groupId, themeId, page, pageSize);

            var theme = await _themeAdminService.GetThemeByIdAsync(themeId);

            List <Breadcrumb> breadcrumb = new List <Breadcrumb>()
            {
                new Breadcrumb("Home", "Index", "Home", new { Area = "" }),
                new Breadcrumb("Groups", "Index", "Group", new { Area = "Admin" }),
                new Breadcrumb("Group results", "GroupResults", "Result", new { Area = "Admin", groupId }),
                new Breadcrumb("Results of the group on the theme")
            };

            var viewModel = new ThemeResultsViewModel
            {
                Group      = group.Number,
                GroupId    = groupId,
                ThemeId    = themeId,
                PageInfo   = results,
                Results    = results.Results,
                Breadcrumb = breadcrumb
            };

            ViewBag.Title       = $"Results of the group {group.Number}";
            ViewBag.SecondTitle = $"Theme \"{theme.Title}\"";
            return(View(viewModel));
        }
        public async Task <IActionResult> Themes(string id)
        {
            ThemeResultsViewModel viewModel = new ThemeResultsViewModel();
            List <Faction>        factions  = await _db.Factions.ToListAsync();

            List <string> factionOptions = new List <string> {
                StaticDetails.AllFactions
            };
            List <string> factionNames = factions.Select(f => f.Name).OrderBy(f => f).ToList();

            foreach (string factionName in factionNames)
            {
                factionOptions.Add(factionName);
            }
            viewModel.FactionOptions = factionOptions;
            if (string.IsNullOrWhiteSpace(id) || !viewModel.FactionOptions.Contains(id))
            {
                viewModel.Faction = StaticDetails.AllFactions;
            }
            else
            {
                viewModel.Faction = id;
            }

            if (viewModel.Faction == StaticDetails.AllFactions)
            {
                List <Theme> themes = await _db.Themes.OrderBy(t => t.Name).ToListAsync();

                List <BattleReport> battleReports = await _db.BattleReports.Where(br => br.ConfirmedByOpponent).OrderByDescending(br => br.DatePlayed).ToListAsync();

                viewModel.ThemeResults = CreateThemeResults(themes, battleReports);
            }
            else
            {
                Faction      faction       = factions.First(f => f.Name == id);
                List <Theme> factionThemes = await _db.Themes.Where(t => t.FactionId == faction.Id).OrderBy(t => t.Name).ToListAsync();

                List <BattleReport> factionBattleReports = await _db.BattleReports.Where(br => br.ConfirmedByOpponent && (br.PostersFaction == id || br.OpponentsFaction == id)).OrderByDescending(br => br.DatePlayed).ToListAsync();

                viewModel.ThemeResults = CreateThemeResults(factionThemes, factionBattleReports);
            }

            return(View(viewModel));
        }