public async Task <SearchPackageResult> Data([FromUri] SearchPackage searchPackage, [FromUri] Guid playerId)
        {
            var player = _playerQueries.GetPlayer(playerId);

            CheckBrand(player.BrandId);

            var request         = Mapper.Map <FilteredDataRequest>(searchPackage);
            var filteredBonuses = await _bonusApiProxy.GetFilteredIssueBonusesAsync(new PlayerFilteredDataRequest
            {
                DataRequest = request,
                PlayerId    = playerId
            });

            var searchPackageResult = new SearchPackageResult
            {
                page    = filteredBonuses.Page,
                total   = filteredBonuses.Total,
                records = filteredBonuses.Records,
                rows    = filteredBonuses.Rows.Select(b => new SearchPackageResultRow
                {
                    id   = b.Id,
                    cell = new object[]
                    {
                        b.Name,
                        b.Code,
                        b.Type,
                        b.Status,
                        b.Description
                    }
                }).ToList()
            };

            return(searchPackageResult);
        }
Example #2
0
        public async Task <SearchPackageResult> GetRedemptionEvents([FromUri] SearchPackage searchPackage, [FromUri] Guid playerId, [FromUri] Guid redemptionId)
        {
            var player = _playerQueries.GetPlayer(playerId);

            CheckBrand(player.BrandId);

            var request         = Mapper.Map <FilteredDataRequest>(searchPackage);
            var filteredBonuses = await _bonusApiProxy.GetFilteredBonusRedemptionEventsAsync(new RedemptionFilteredDataRequest
            {
                DataRequest       = request,
                BonusRedemptionId = redemptionId
            });

            var searchPackageResult = new SearchPackageResult
            {
                page    = filteredBonuses.Page,
                total   = filteredBonuses.Total,
                records = filteredBonuses.Records,
                rows    = filteredBonuses.Rows.Select(@event => new SearchPackageResultRow
                {
                    id   = @event.Id,
                    cell = new object[]
                    {
                        Format.FormatDate(@event.Created),
                        @event.DataType,
                        GetData(@event)
                    }
                }).ToList()
            };

            return(searchPackageResult);
        }
Example #3
0
        public async Task <SearchPackageResult> Data([FromUri] SearchPackage searchPackage, [FromUri] Guid playerId)
        {
            var player = _playerQueries.GetPlayer(playerId);

            CheckBrand(player.BrandId);

            var brand = _brandQueries.GetBrand(player.BrandId);
            var rules = searchPackage.AdvancedFilter.Rules.Where(r => r.Field == "CreatedOn");

            foreach (var rule in rules)
            {
                var dateInBrandsTimezone = DateTime.Parse(rule.Data).ToBrandDateTimeOffset(brand.TimezoneId).ToString("O");
                rule.Data = dateInBrandsTimezone;
            }

            var request = Mapper.Map <FilteredDataRequest>(searchPackage);

            request.Filters.Where(f => f.Field == "BonusType").ForEach(f => f.Field = "Bonus.Type");
            var filteredBonuses = await _bonusApiProxy.GetFilteredBonusRedemptionAsync(new PlayerFilteredDataRequest
            {
                DataRequest = request,
                PlayerId    = playerId
            });

            var searchPackageResult = new SearchPackageResult
            {
                page    = filteredBonuses.Page,
                total   = filteredBonuses.Total,
                records = filteredBonuses.Records,
                rows    = filteredBonuses.Rows.Select(redemption => new SearchPackageResultRow
                {
                    id   = redemption.Id,
                    cell = new object[]
                    {
                        redemption.Bonus.Name,
                        redemption.Bonus.Type.ToString(),
                        Format.FormatDate(redemption.CreatedOn),
                        redemption.ActivationState.ToString(),
                        redemption.Amount.Format(),
                        redemption.Rollover.Format(),
                        (redemption.Rollover - redemption.RolloverLeft).Format(),
                        redemption.RolloverLeft.Format(),
                        redemption.RolloverState == RolloverStatus.Active //can be canceled
                    }
                }).ToList()
            };

            return(searchPackageResult);
        }
        public async Task <SearchPackageResult> Data([FromUri] SearchPackage searchPackage)
        {
            VerifyPermission(Permissions.View, Modules.BonusTemplateManager);
            VerifyPermission(Permissions.View, Modules.BonusManager);

            var request = Mapper.Map <FilteredDataRequest>(searchPackage);
            var brandFilterSelections = _adminQueries.GetBrandFilterSelections().ToList();
            var filteredTemplates     = await _bonusApiProxy.GetFilteredBonusTemplatesAsync(new BrandFilteredDataRequest
            {
                DataRequest  = request,
                BrandFilters = brandFilterSelections
            });

            var licensees           = _brandQueries.GetAllLicensees().Select(l => new { l.Name, Brands = l.Brands.Select(b => new { b.Id, b.Name }) }).ToList();
            var searchPackageResult = new SearchPackageResult
            {
                page    = filteredTemplates.Page,
                total   = filteredTemplates.Total,
                records = filteredTemplates.Records,
                rows    = filteredTemplates.Rows.Select(template => new SearchPackageResultRow
                {
                    id   = template.Id,
                    cell = new object[]
                    {
                        template.Name,
                        licensees.Single(l => l.Brands.Select(b => b.Id).Contains(template.BrandId)).Name,
                        licensees.SelectMany(l => l.Brands).Single(b => b.Id == template.BrandId).Name,
                        template.Mode.ToString(),
                        template.Type,
                        template.Status,
                        template.CreatedBy,
                        Format.FormatDate(template.CreatedOn),
                        template.UpdatedBy,
                        Format.FormatDate(template.UpdatedOn),
                        template.CanBeEdited,
                        template.CanBeDeleted
                    }
                }).ToList()
            };

            return(searchPackageResult);
        }
Example #5
0
        public async Task <SearchPackageResult> Data([FromUri] SearchPackage searchPackage)
        {
            VerifyPermission(Permissions.View, Modules.BonusManager);

            var request = Mapper.Map <FilteredDataRequest>(searchPackage);
            var brandFilterSelections = _adminQueries.GetBrandFilterSelections().ToList();
            var filteredBonuses       = await _bonusApiProxy.GetFilteredBonusesAsync(new BrandFilteredDataRequest
            {
                BrandFilters = brandFilterSelections,
                DataRequest  = request
            });

            var licensees           = _brandQueries.GetAllLicensees().Select(l => new { l.Name, Brands = l.Brands.Select(b => new { b.Id, b.Name }) }).ToList();
            var searchPackageResult = new SearchPackageResult
            {
                page    = filteredBonuses.Page,
                total   = filteredBonuses.Total,
                records = filteredBonuses.Records,
                rows    = filteredBonuses.Rows.Select(bonus => new SearchPackageResultRow
                {
                    id   = bonus.Id,
                    cell = new object[]
                    {
                        bonus.Name,
                        bonus.Code,
                        bonus.Type.ToString(),
                        bonus.Mode.ToString(),
                        Format.FormatDate(bonus.ActiveFrom, false),
                        Format.FormatDate(bonus.ActiveTo, false),
                        licensees.Single(l => l.Brands.Select(b => b.Id).Contains(bonus.BrandId)).Name,
                        licensees.SelectMany(l => l.Brands).Single(b => b.Id == bonus.BrandId).Name,
                        bonus.IsActive,
                        bonus.CreatedBy,
                        Format.FormatDate(bonus.CreatedOn),
                        bonus.UpdatedBy,
                        Format.FormatDate(bonus.UpdatedOn)
                    }
                }).ToList()
            };

            return(searchPackageResult);
        }