コード例 #1
0
        public async Task Update(GameModel model)
        {
            var squadDTOs = new List <SquadDTO>();

            if (model.MyPlayer?.Squads != null)
            {
                foreach (Squad squad in model.MyPlayer.Squads)
                {
                    var squadDTO = new SquadDTO
                    {
                        Id    = squad.Id,
                        Count = squad.Count
                    };
                    squadDTOs.Add(squadDTO);
                }
            }
            var player = new PlayerDTO
            {
                GameId   = _game.GameId,
                PlayerId = model.MyPlayer.PlayerId,
                Squads   = squadDTOs
            };

            await _client.Update(player);
        }
コード例 #2
0
        private PlayerDTO PlayerToDTO(PlayerModel playerModel)
        {
            var squadDTOs = new List <SquadDTO>();

            foreach (SquadModel squadModel in playerModel.Squads)
            {
                var squadDTO = new SquadDTO
                {
                    SquadId   = squadModel.SquadId,
                    Armaments = squadModel.Armaments,
                    Stats     = squadModel.Stats
                };
                squadDTOs.Add(squadDTO);
            }
            var playerDTO = new PlayerDTO
            {
                GameId   = playerModel.GameId,
                PlayerId = playerModel.PlayerId,
                Squads   = squadDTOs
            };

            return(playerDTO);
        }