Пример #1
0
        public virtual HttpResponseMessage GetPlayers([FromUri] int gamingGroupId)
        {
            var results = _playerRetriever.GetAllPlayers(gamingGroupId);

            var playerIds = results.Select(x => x.Id).ToList();
            //--include the current player so we can attempt to get their email address as well
            var playerIdToRegisteredUserEmailAddressDictionary =
                _playerRetriever.GetRegisteredUserEmailAddresses(playerIds, CurrentUser);

            var playerSearchResultsMessage = new PlayersSearchResultsMessage();

            foreach (var player in results)
            {
                var playerSearchResultMessage = new PlayerSearchResultMessage
                {
                    Active   = player.Active,
                    PlayerId = player.Id,
                    CurrentNemesisPlayerId = player.NemesisId,
                    PlayerName             = player.Name,
                    NemeStatsUrl           = AbsoluteUrlBuilder.GetPlayerDetailsUrl(player.Id)
                };

                if (playerIdToRegisteredUserEmailAddressDictionary.ContainsKey(player.Id))
                {
                    playerSearchResultMessage.RegisteredUserGravatarUrl = UIHelper.BuildGravatarUrl(playerIdToRegisteredUserEmailAddressDictionary[player.Id]);
                }

                playerSearchResultsMessage.Players.Add(playerSearchResultMessage);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, playerSearchResultsMessage));
        }
Пример #2
0
        public virtual HttpResponseMessage GetPlayers([FromUri] int gamingGroupId)
        {
            var results = playerRetriever.GetAllPlayers(gamingGroupId);

            var playerSearchResultsMessage = new PlayersSearchResultsMessage
            {
                Players = results.Select(player => new PlayerSearchResultMessage
                {
                    Active   = player.Active,
                    PlayerId = player.Id,
                    CurrentNemesisPlayerId = player.NemesisId,
                    PlayerName             = player.Name
                }).ToList()
            };

            return(Request.CreateResponse(HttpStatusCode.OK, playerSearchResultsMessage));
        }