Example #1
0
        private void SendHighDepositBonusSmsNotifications(Player player)
        {
            var highDepositBonuses = _bonusQueries.GetCurrentVersionBonuses(player.Data.Brand.Id)
                                     .Where(x => x.Template.Info.TemplateType == BonusType.HighDeposit)
                                     .ToList()
                                     .Select(b => new Entities.Bonus(b));

            foreach (var bonus in highDepositBonuses)
            {
                var bonusRewardThreshold = bonus.CalculateRewardThreshold(player);

                if (bonusRewardThreshold == null)
                {
                    continue;
                }

                var model = new HighDepositReminderModel
                {
                    Currency              = player.Data.CurrencyCode,
                    BonusAmount           = bonusRewardThreshold.BonusAmount,
                    RemainingAmount       = bonusRewardThreshold.RemainingAmount,
                    DepositAmountRequired = bonusRewardThreshold.DepositAmountRequired
                };

                _serviceBus.PublishMessage(new SendPlayerAMessage
                {
                    PlayerId              = player.Data.Id,
                    MessageType           = MessageType.HighDepositReminder,
                    MessageDeliveryMethod = MessageDeliveryMethod.Sms,
                    Model = model
                });
            }
        }
Example #2
0
        public void ChangeBonusStatus(ToggleBonusStatus model)
        {
            var validationResult = _bonusQueries.GetValidationResult(model);

            if (validationResult.IsValid == false)
            {
                throw new RegoException(validationResult.Errors.First().ErrorMessage);
            }

            var bonusToUpdate = _bonusQueries.GetCurrentVersionBonuses().Single(b => b.Id == model.Id);
            var isActive      = model.IsActive;

            if (bonusToUpdate.IsActive == isActive)
            {
                return;
            }

            bonusToUpdate.IsActive = isActive;
            AddUpdatedBonus(bonusToUpdate);

            if (isActive)
            {
                _eventBus.Publish(new BonusActivated
                {
                    AggregateId  = bonusToUpdate.Id,
                    Remarks      = model.Remarks,
                    EventCreated = bonusToUpdate.UpdatedOn.Value
                });
            }
            else
            {
                _eventBus.Publish(new BonusDeactivated
                {
                    AggregateId  = bonusToUpdate.Id,
                    Remarks      = model.Remarks,
                    EventCreated = bonusToUpdate.UpdatedOn.Value
                });
            }
        }