Exemple #1
0
        public GetPlayersOutput GetPlayers(GetPlayerInput input)
        {
            Logger.Info($" get player input :: {JsonConvert.SerializeObject(input)}");
            Logger.Info($" get player input :: {input}");
            Logger.Warn($"session :: {JsonConvert.SerializeObject(Session)}");

            if (!string.IsNullOrEmpty(input.PlayerName))
            {
                var playerEntityList = _playeRepository.GetAllList(a => a.PlayerName.Contains(input.PlayerName));
                return(new GetPlayersOutput
                {
                    Players = playerEntityList.Select(a => new PlayerDto
                    {
                        PlayerID = a.Id,
                        PlayerName = a.PlayerName
                    })
                });
            }

            if (input.MapID > 0)
            {
                var playerEntityList = _playeRepository.GetPlayersWithMap(input.MapID);

                return(new GetPlayersOutput
                {
                    Players = playerEntityList.Select(a => new PlayerDto
                    {
                        PlayerID = a.Id,
                        PlayerName = a.PlayerName
                    })
                });
            }

            throw new UserFriendlyException("input error");
        }
        public async Task <ListResultDto <PlayerListItem> > GetAllPlayer(GetPlayerInput input)
        {
            var playerLists = await _playerRepository
                              .GetAll()
                              .WhereIf(
                !input.Filter.IsNullOrEmpty(),
                s => s.FirstName.Contains(input.Filter) ||
                s.LastName.Contains(input.Filter) ||
                s.Email.Contains(input.Filter) ||
                s.PhoneNumber.ToString().Contains(input.Filter)
                )
                              .OrderBy(o => o.CreationTime)
                              .ToListAsync();

            return(new ListResultDto <PlayerListItem>(ObjectMapper.Map <List <PlayerListItem> >(playerLists)));
        }