public async Task AddBonusOperationAsync(BonusOperation bonusOperation) { var campaignId = bonusOperation.CampaignId.ToGuid(); var bonusIssuedEvent = new BonusIssuedEvent { OperationId = Guid.NewGuid(), Amount = bonusOperation.Reward, CampaignId = campaignId, ConditionId = bonusOperation.BonusOperationType == Domain.Enums.BonusOperationType.CampaignReward ? Guid.Empty : bonusOperation.ConditionId.ToGuid(), PartnerId = bonusOperation.PartnerId, LocationId = bonusOperation.LocationId, UnitLocationCode = bonusOperation.UnitLocationCode, CustomerId = bonusOperation.CustomerId, BonusOperationType = _mapper.Map <BonusOperationType>(bonusOperation.BonusOperationType), TimeStamp = bonusOperation.TimeStamp, ReferralId = bonusOperation.ReferralId }; // Zero reward operations are not accepted by blockchain facade if (bonusIssuedEvent.Amount > 0) { await _bonusIssuedPublisher.PublishAsync(bonusIssuedEvent); _log.Info( $"Bonus issued: {bonusIssuedEvent.ToJson()}", bonusIssuedEvent.BonusOperationType, process: nameof(AddBonusOperationAsync)); } }
private async Task ProcessMessageAsync(BonusIssuedEvent msg) { await _cashInService.ProcessBonusIssuedEventAsync(new BonusIssuedDto { CustomerId = msg.CustomerId, OperationId = msg.OperationId, Amount = msg.Amount, BonusType = msg.BonusOperationType.ToString(), CampaignId = msg.CampaignId, ConditionId = msg.ConditionId, UnitLocationCode = msg.UnitLocationCode, PartnerId = msg.PartnerId, LocationId = msg.LocationId, TimeStamp = msg.TimeStamp, ReferralId = msg.ReferralId }); _log.Info($"Processed bonus event", msg); }