Beispiel #1
0
        private async Task PublishOTP(ReferralLead createdReferralLead)
        {
            var offerToPurchase = new OfferToPurchase
            {
                CurrencyCode         = "AED",
                DiscountAmount       = 1,
                NetPropertyPrice     = 1,
                ReferId              = createdReferralLead.Id,
                SellingPropertyPrice = 1,
                Timestamp            = DateTime.UtcNow,
                VatAmount            = 1
            };
            await _offerToPurchasePurchaseRepository.InsertAsync(offerToPurchase);

            var lead = await _referralLeadRepository.GetAsync(offerToPurchase.ReferId);

            await _offerToPurchasePublisher.PublishAsync(new OfferToPurchaseByLeadEvent
            {
                AgentId              = lead.AgentId.ToString(),
                TimeStamp            = offerToPurchase.Timestamp,
                CurrencyCode         = offerToPurchase.CurrencyCode,
                VatAmount            = offerToPurchase.VatAmount,
                DiscountAmount       = offerToPurchase.DiscountAmount,
                NetPropertyPrice     = offerToPurchase.NetPropertyPrice,
                SellingPropertyPrice = offerToPurchase.SellingPropertyPrice,
                ReferralId           = lead.Id.ToString()
            });
        }
        public async Task <(bool isSuccessful, string errorMessage)> ProcessOfferToPurchaseAsync(
            OfferToPurchase offerToPurchase)
        {
            if (!await _referralLeadRepository.DoesExistAsync(offerToPurchase.ReferId))
            {
                return(false, $"Referral lead with id '{offerToPurchase.ReferId} does not exist.'");
            }

            await _offerToPurchasePurchaseRepository.InsertAsync(offerToPurchase);

            var lead = await _referralLeadRepository.GetAsync(offerToPurchase.ReferId);

            await _offerToPurchasePublisher.PublishAsync(new OfferToPurchaseByLeadEvent
            {
                AgentId              = lead.AgentId.ToString(),
                TimeStamp            = offerToPurchase.Timestamp,
                CurrencyCode         = offerToPurchase.CurrencyCode, VatAmount = offerToPurchase.VatAmount,
                DiscountAmount       = offerToPurchase.DiscountAmount, NetPropertyPrice = offerToPurchase.NetPropertyPrice,
                SellingPropertyPrice = offerToPurchase.SellingPropertyPrice,
                CampaignId           = lead.CampaignId.Value,
                UnitLocationCode     = offerToPurchase.UnitLocationCode,
                ReferralId           = lead.Id.ToString()
            });

            return(true, string.Empty);
        }
        public async Task InsertAsync(OfferToPurchase offerToPurchase)
        {
            using (var context = _msSqlContextFactory.CreateDataContext())
            {
                await context.AddAsync(_mapper.Map <OfferToPurchaseEntity>(offerToPurchase));

                await context.SaveChangesAsync();
            }
        }