Example #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));
        }
Example #2
0
        private IEnumerable <SelectListItem> GetAllPlayers(ApplicationUser currentUser)
        {
            List <Player>         allPlayers           = playerRetriever.GetAllPlayers(currentUser.CurrentGamingGroupId);
            List <SelectListItem> allPlayersSelectList = allPlayers.Select(item => new SelectListItem
            {
                Text  = item.Name,
                Value = item.Id.ToString()
            }).ToList();

            return(allPlayersSelectList);
        }
Example #3
0
        internal virtual void AddPlayersToViewModel(int currentGamingGroupId, SearchViewModel searchViewModel, int?selectedPlayerId)
        {
            var players = _playerRetriever.GetAllPlayers(currentGamingGroupId, false);
            var playerSelectListItems = players.Select(player => new SelectListItem
            {
                Text     = player.Name,
                Value    = player.Id.ToString(),
                Selected = player.Id == selectedPlayerId
            }).ToList();

            searchViewModel.Players = playerSelectListItems;
        }
Example #4
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));
        }