Exemplo n.º 1
0
        private async Task PublishCommissionEvents(ReferralLead createdReferralLead)
        {
            var propertyPurchase = new PropertyPurchase
            {
                CurrencyCode         = "AED",
                DiscountAmount       = 1,
                NetPropertyPrice     = 1,
                ReferralLeadId       = createdReferralLead.Id,
                SellingPropertyPrice = 1,
                Timestamp            = DateTime.UtcNow,
                VatAmount            = 1
            };

            await _propertyPurchaseRepository.InsertAsync(propertyPurchase);

            var lead = await _referralLeadRepository.GetAsync(propertyPurchase.ReferralLeadId);
        }
        public async Task <Guid> AddRealEstatePurchase(PropertyPurchase propertyPurchase)
        {
            var lead = await _referralLeadRepository.GetAsync(propertyPurchase.ReferralLeadId);

            if (lead == null)
            {
                throw new ReferralDoesNotExistException($"Referral lead with id '{propertyPurchase.ReferralLeadId} does not exist.'");
            }

            // If duplicate comes we want to skip releasing stake and inserting new entity
            if (!await _propertyPurchaseRepository.PropertyPurchaseExistsAsync(propertyPurchase.ReferralLeadId))
            {
                await _propertyPurchaseRepository.InsertAsync(propertyPurchase);

                if (lead.StakeEnabled)
                {
                    await _stakeService.ReleaseStake(lead.Id.ToString("D"), lead.CampaignId.Value, EstatePurchaseConditionName);
                }
            }

            return(lead.CampaignId.Value);
        }