示例#1
0
        PageUserPrizes(int userId, BaseFilter filter = default(BaseFilter))
        {
            VerifyManagementPermission();

            int siteId = GetCurrentSiteId();

            if (filter == null)
            {
                filter = new BaseFilter();
            }

            var prizes = await _prizeWinnerRepository
                         .PageByWinnerAsync(siteId, userId, (int)filter.Skip, (int)filter.Take);

            foreach (var prize in prizes)
            {
                if (prize.DrawingId != null)
                {
                    var drawing = await _drawingRepository.GetByIdAsync((int)prize.DrawingId);

                    prize.PrizeName = drawing.Name;
                    prize.PrizeRedemptionInstructions = drawing.RedemptionInstructions;
                }
                else if (prize.TriggerId != null)
                {
                    var trigger = await _triggerRepository.GetByIdAsync((int)prize.TriggerId);

                    prize.PrizeName = trigger.AwardPrizeName;
                    prize.PrizeRedemptionInstructions = trigger.AwardPrizeRedemptionInstructions;
                }
            }

            return(new DataWithCount <ICollection <PrizeWinner> >
            {
                Data = prizes,
                Count = await _prizeWinnerRepository.CountByWinningUserId(siteId, userId)
            });
        }
示例#2
0
        PageUserPrizes(int userId, BaseFilter filter = default(BaseFilter))
        {
            VerifyManagementPermission();

            int siteId = GetCurrentSiteId();

            if (filter == null)
            {
                filter = new BaseFilter();
            }

            var prizes = await _prizeWinnerRepository
                         .PageByWinnerAsync(siteId, userId, (int)filter.Skip, (int)filter.Take);

            foreach (var prize in prizes)
            {
                if (prize.DrawingId != null)
                {
                    var drawing = await _drawingRepository.GetByIdAsync((int)prize.DrawingId);

                    prize.PrizeName = drawing.Name;
                    prize.PrizeRedemptionInstructions = drawing.RedemptionInstructions;

                    var drawingCritera = await _drawingCriterionRepository
                                         .GetByIdAsync(drawing.DrawingCriterionId);

                    prize.AvailableAtBranch = drawingCritera.BranchName;
                    prize.AvailableAtSystem = drawingCritera.SystemName;
                }
                else if (prize.TriggerId != null)
                {
                    var trigger = await _triggerRepository.GetByIdAsync((int)prize.TriggerId);

                    prize.AvailableAtBranch           = trigger.LimitToBranchName;
                    prize.AvailableAtSystem           = trigger.LimitToSystemName;
                    prize.PrizeName                   = trigger.AwardPrizeName;
                    prize.PrizeRedemptionInstructions = trigger.AwardPrizeRedemptionInstructions;
                }
                else if (prize.VendorCodeId != null)
                {
                    var vendorCode = await _vendorCodeRepository
                                     .GetByIdAsync((int)prize.VendorCodeId);

                    var vendorCodeType = await _vendorCodeTypeRepository
                                         .GetByIdAsync(vendorCode.VendorCodeTypeId);

                    var branch = await _branchRepository.GetByIdAsync((int)vendorCode.BranchId);

                    var system = await _systemRepository.GetByIdAsync(branch.SystemId);

                    prize.PrizeName = $"{vendorCodeType.Description}: {vendorCode.Details}";
                    prize.PrizeRedemptionInstructions = $"Give customer {vendorCode.Details} and click the green redemption button.";
                    prize.AvailableAtBranch           = branch.Name;
                    prize.AvailableAtSystem           = system.Name;
                }
            }

            return(new DataWithCount <ICollection <PrizeWinner> >
            {
                Data = prizes,
                Count = await _prizeWinnerRepository.CountByWinningUserId(siteId, userId)
            });
        }
示例#3
0
 public async Task <Trigger> GetByIdAsync(int id)
 {
     VerifyManagementPermission();
     return(await _triggerRepository.GetByIdAsync(id));
 }