Пример #1
0
        public static Team ConvertToDbModel(TeamModel team)
        {
            var dbTeam = new Team()
            {
                teamId   = team.TeamId,
                teamName = team.Name,
                Image    = team.BannerImageFile == null ? null : new Image()
                {
                    imageFileName    = team.BannerImageFile.FileName,
                    imageContent     = ImageController.ConvertToBytes(team.BannerImageFile),
                    imageContentType = team.BannerImageFile.ContentType
                },
            };

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

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

            return(dbTeam);
        }
Пример #2
0
        public static Player ConvertToDbModel(PlayerModel player)
        {
            var dbPlayer = new Player()
            {
                playerId         = player.PlayerId,
                playerFirstName  = player.FirstName,
                playerLastName   = player.LastName,
                playerScreenName = player.ScreenName,
                Image            = player.AvatarImageFile != null ? new Image()
                {
                    imageFileName    = player.AvatarImageFile.FileName,
                    imageContent     = ImageController.ConvertToBytes(player.AvatarImageFile),
                    imageContentType = player.AvatarImageFile.ContentType,
                } : null,
                teamId = player.TeamId,
            };

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


            return(dbPlayer);
        }