コード例 #1
0
        public Notification GetNotification(int playerId, int? matchId)
        {
            Notification result = new Notification() { Notifications = new List<Notification.NotificationMatch>() };

            using (IGameDataService gameDataService = new GameDataService())
            {
                IEnumerable<Match> matches = gameDataService.GetPendingMatchesForPlayer(playerId);

                foreach (var match in matches)
                {
                    Player opponent = gameDataService.GetPlayer(match.PlayerOneId == playerId ? match.PlayerTwoId : match.PlayerOneId);
                    result.Notifications.Add(new Notification.NotificationMatch()
                                            {
                                                OpponentName = opponent.PlayerName,
                                                MatchId = match.MatchId
                                            });
                }
            }

            return result;
        }