Esempio n. 1
0
        public async Task <IActionResult> GetAllPlayers(int teamID)
        {
            var request  = new GetPlayersRequest(teamID, this._dataSourceProvider.UseDb);
            var response = await this._mediator.Send(request);

            return(this.Ok(response));
        }
Esempio n. 2
0
        public Task <IEnumerable <Player> > Handle(GetPlayersRequest request, CancellationToken cancellationToken)
        {
            if (request.UseDb)
            {
                return(this._db.GetAllPlayers(request.TeamID));
            }

            var allPlayers = this._mock.GetPlayers();
            var filtered   = allPlayers.Where(x => x.TeamID == request.TeamID);

            return(Task.FromResult(filtered));
        }
Esempio n. 3
0
        private List <IFilterOption> BuildFilters(GetPlayersRequest request)
        {
            var filters = new List <IFilterOption>();

            if (!String.IsNullOrWhiteSpace(request.Username))
            {
                filters.Add(new FilterOption
                {
                    PropertyName = "Username",
                    Operator     = FilterOperator.Contain,
                    Value        = request.Username
                });
            }
            if (!String.IsNullOrWhiteSpace(request.BrandName))
            {
                filters.Add(new FilterOption
                {
                    PropertyName = "BrandName",
                    Operator     = FilterOperator.Contain,
                    Value        = request.BrandName
                });
            }
            if (!String.IsNullOrWhiteSpace(request.LicenseeName))
            {
                filters.Add(new FilterOption
                {
                    PropertyName = "LicenseeName",
                    Operator     = FilterOperator.Contain,
                    Value        = request.LicenseeName
                });
            }
            if (!String.IsNullOrWhiteSpace(request.Currency))
            {
                filters.Add(new FilterOption
                {
                    PropertyName = "DefaultWalletCurrencyCode",
                    Operator     = FilterOperator.Equal,
                    Value        = request.Currency
                });
            }
            return(filters);
        }
Esempio n. 4
0
        public async Task <GetPlayersResponse> GetPlayersAsync([FromUri] GetPlayersRequest request)
        {
            var pagableParam = new PagableQueryParameter
            {
                SortOption    = new SortOption(request.SortBy, request.OrderBy.ToLower().Equals("desc")),
                FilterOptions = BuildFilters(request),
                Page          = request.Page,
                PageSize      = request.Rows
            };

            int totalCount = 0;
            var players    = await _playerQueries.GetPlayersAsync(pagableParam, out totalCount);

            var playerModels = from p in players select ConvertToPlayerModel(p);

            return(new GetPlayersResponse
            {
                Valid = true,
                TotalCount = totalCount,
                Players = playerModels.ToArray()
            });
        }
 public Task <IActionResult> GetAllPlayers([FromQuery] GetPlayersRequest request)
 {
     return(this.HandleRequest <GetPlayersRequest, GetPlayersResponse>(request));
 }