示例#1
0
        public async Task <Guid> CreateSession(Guid?existingId, List <Player> players)
        {
            var sessionId = existingId ?? Guid.NewGuid();

            if (existingId.HasValue)
            {
                var existingPlayers = await playerRepository.GetPlayers(existingId.Value);

                if (existingPlayers != null && existingPlayers.Any())
                {
                    await RemoveStalePlayers(existingId.Value, players, existingPlayers);
                }
            }

            await playerRepository.CreateUpdatePlayers(sessionId, players);

            return(sessionId);
        }