Exemple #1
0
        public EliteMedalsViewModel(
            int season,
            Dictionary <string, Player> playersDict,
            EliteMedals eliteMedals,
            SeasonResults seasonResults)
        {
            this.season = season;
            var players = new List <PlayerInfo>();

            foreach (string playerId in playersDict.Keys)
            {
                Player player = playersDict[playerId];
                EliteMedals.EliteMedal existingMedal = eliteMedals.GetExistingMedal(playerId);
                HashSet <Tuple <SeasonResults.PlayerResult, bool> > topThreeResults = seasonResults.GetTopThreeResults(playerId, existingMedal.Value);
                FormattedMedal formattedExistingMedal = eliteMedals.GetFormattedExistingMedal(playerId);
                FormattedMedal nextMedal  = eliteMedals.GetNextMedal(playerId);
                var            playerInfo = new PlayerInfo(
                    playerId,
                    player.Name,
                    player.PersonalNumber,
                    topThreeResults,
                    existingMedal.Value,
                    formattedExistingMedal,
                    nextMedal);
                players.Add(playerInfo);
            }

            Players = players.ToArray();
        }
Exemple #2
0
    public ActionResult EditMedals(int id)
    {
        Player      player      = CompositionRoot.DocumentSession.Load <Player>(id);
        EliteMedals eliteMedals = CompositionRoot.DocumentSession.Load <EliteMedals>(Domain.EliteMedals.TheId);

        EliteMedals.EliteMedal eliteMedal = eliteMedals.GetExistingMedal(player.Id);
        EditMedalsViewModel    viewModel  = new(
            player.Name,
            eliteMedal.Value,
            eliteMedal.CapturedSeason.GetValueOrDefault(),
            CompositionRoot.DocumentSession.LatestSeasonOrDefault(DateTime.Now.Year));

        return(View(viewModel));
    }