Beispiel #1
0
        public static PlayerModel ConvertToViewModel(Player dbPlayer)
        {
            var player = new PlayerModel()
            {
                PlayerId      = dbPlayer.playerId,
                FirstName     = dbPlayer.playerFirstName,
                LastName      = dbPlayer.playerLastName,
                ScreenName    = dbPlayer.playerScreenName,
                AvatarImageId = dbPlayer.imageId == null ? -1 : (int)dbPlayer.imageId,
                TeamName      = dbPlayer.Team.teamName,
                TeamId        = dbPlayer.teamId == null ? -1 : (int)dbPlayer.teamId,
            };

            foreach (var stat in dbPlayer.Stats)
            {
                player.Stats.Add(StatController.ConvertToViewModel(stat));
            }

            return(player);
        }
Beispiel #2
0
        public static TeamModel ConvertToViewModel(Team dbTeam)
        {
            var team = new TeamModel()
            {
                TeamId        = dbTeam.teamId,
                Name          = dbTeam.teamName,
                BannerImageId = (dbTeam.imageId == null ? -1 : (int)dbTeam.imageId),
            };

            foreach (var player in dbTeam.Players)
            {
                team.Players.Add(PlayerController.ConvertToViewModel(player));
            }

            foreach (var stat in dbTeam.Stats)
            {
                team.Stats.Add(StatController.ConvertToViewModel(stat));
            }

            return(team);
        }