Example #1
0
        public IList <DivisionStandingsViewModel> GetTournamentStandings(int id)
        {
            var result  = new List <DivisionStandingsViewModel>();
            var entries = _gameReportService.GetStandings(id);

            foreach (var entry in entries.Divisions)
            {
                var standings = new DivisionStandingsViewModel {
                    LastUpdateTime = entry.LastUpdateTime,
                    DivisionName   = entry.DivisionName,
                    StandingsTable = entry.Standings.Select(StandingsEntryViewModel.Map).ToList()
                };
                StandingsEntryViewModel.SetPositions(standings.StandingsTable);
                result.Add(standings);
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// Renders view with standings of the tournament specified by identifier.
        /// </summary>
        /// <param name="tournamentId">Identifier of the tournament.</param>
        /// <param name="tournamentName">Name of the tournament.</param>
        /// <returns>View with standings of the tournament.</returns>
        public ActionResult Standings(int tournamentId, string tournamentName)
        {
            if (_gameReportService.IsStandingAvailable(tournamentId))
            {
                var standings = _gameReportService.GetStandings(tournamentId);
                var pivots    = _gameReportService.GetPivotStandings(tournamentId);

                var mapedStandings = standings.Divisions
                                     .Select(item =>
                {
                    var standingsTable = DivisionStandingsViewModel.Map(item);
                    TeamStandingsViewModelBase.SetPositions(standingsTable.StandingsEntries);
                    return(standingsTable);
                })
                                     .ToList();

                var pivotTables = pivots.Divisions.Select(item => new PivotTableViewModel(item)).ToList();

                var standingsViewModel = new StandingsViewModel
                {
                    TournamentId   = tournamentId,
                    TournamentName = tournamentName,
                    StandingsTable = mapedStandings,
                    PivotTable     = pivotTables
                };

                return(View(standingsViewModel));
            }
            else
            {
                var standingsViewModel = new StandingsViewModel
                {
                    TournamentId   = tournamentId,
                    TournamentName = tournamentName,
                    Message        = Resources.UI.GameReportViews.StandingsNotAvaliable
                };
                return(View("StandingsNotAvailable", standingsViewModel));
            }
        }