示例#1
0
        // GET: /user/statistics/player/{playerName}/league/{leagueName}/season/{season}/round/{round}
        public ActionResult PlayerRound(string playerName, string leagueName, string season, int round)
        {
            var playerId         = Players.GetIdByName(playerName);
            var leagueId         = Leagues.GetIdByName(leagueName);
            var seasonPeriod     = Seasons.GetSeasonPeriodFromUrlParameter(season, '-');
            var seasonId         = Seasons.GetIdByPeriod(seasonPeriod);
            var leaguesSeasonsId = LeaguesSeasons.GetIdByLeagueAndSeason(leagueId, seasonId);
            var roundId          = Rounds.GetRoundId(round, leaguesSeasonsId);
            var statistics       = Statistics.PlayerRoundStats(playerId, roundId);

            return(View("PlayerLeague", statistics));
        }
示例#2
0
        // GET: Leagues/Details/5
        public ActionResult Details(int id, string period = "")
        {
            var    league = this.Data.Leagues.GetById(id);
            Season season;

            if (!String.IsNullOrEmpty(period))
            {
                var seasonId = Seasons.GetIdByPeriod(period);
                season = this.Data.Seasons.GetById(seasonId);
            }
            else
            {
                season = this.Data.Seasons.All().OrderByDescending(s => s.EndYear).FirstOrDefault();
            }

            if (league == null || season == null)
            {
                return(HttpNotFound());
            }
            // TODO Get the teams per leagueSeason

            var leagueSeason   = LeaguesSeasons.GetLeaguesSeasons(id, season.Id);
            var roundsIds      = Rounds.GetIdsByLeaguesSeasonsId(leagueSeason.Id);
            var rounds         = new List <RoundsViewModel>();
            var leaguesSeasons = this.Data.LeaguesSeasons
                                 .All()
                                 .Where(ls => ls.LeagueId == league.Id)
                                 .Select(ls => new LeaguesSeasonsViewModel {
                LeagueId = ls.LeagueId, StartYear = ls.Season.StartYear, EndYear = ls.Season.EndYear
            })
                                 .ToList();

            foreach (var rnd in roundsIds)
            {
                var round = this.Data.Rounds.All().Project().To <RoundsViewModel>().FirstOrDefault(r => r.Id == rnd);
                round.LeagueName = league.Name;
                round.Season     = string.Format("{0}-{1}", season.StartYear, season.EndYear);
                rounds.Add(round);
            }

            return(View(Tuple.Create(rounds, leaguesSeasons)));
        }