Example #1
0
        public async Task Handle(InqueryHistoryStatusChangedToParsedDomainEvent @event, CancellationToken cancellationToken)
        {
            //Send a new lead added email
            //var emailNeedsToBeSent = new EmailNeedsToBeSentIntegrationEvent
            //{
            //    //Body = mailBody,
            //    IsBodyHtml = true,
            //    //Subject = subject,
            //    FromEmail = "*****@*****.**",
            //    FromName = "Admin",
            //    To = new[] { @event.InqueryHistory.AgentEmail },
            //    ReplyTo = "*****@*****.**",
            //    AggregateId = @event.InqueryHistory.Id,
            //    TemplateId = "954b9208-176d-44e8-af2a-8bed61e88631", //keep it hardcoded for now
            //    MergeFields = GetMergeField(@event.InqueryHistory.AgentInfo, @event)
            //};

            //eventBus.Publish(emailNeedsToBeSent);

            var createContactIntegrationEvent = new CreateContactIntegrationEvent()
            {
                AggregateId = @event.InqueryHistory.Id,
                Source      = @event.InqueryHistory.InquiryType == InquiryType.BuyInquiry ? "BuyInquiry" : "RentInquiry",

                Email     = @event.InqueryHistory.CustomerInfo.Email,
                Phone     = @event.InqueryHistory.CustomerInfo.Phone,
                City      = @event.InqueryHistory.CustomerInfo.City,
                Company   = @event.InqueryHistory.CustomerInfo.Company,
                Address   = @event.InqueryHistory.CustomerInfo.Address,
                Country   = @event.InqueryHistory.CustomerInfo.Country,
                Firstname = @event.InqueryHistory.CustomerInfo.Firstname,
                Lastname  = @event.InqueryHistory.CustomerInfo.Lastname,
                Aboutme   = @event.InqueryHistory.CustomerInfo.Aboutme,
                OwnerId   = @event.InqueryHistory.AgentInfo.Id,
                Ownername = $"{@event.InqueryHistory.AgentInfo.Firstname} {@event.InqueryHistory.AgentInfo.Lastname}"
            };

            eventBus.Publish(createContactIntegrationEvent);

            var emailNeedsToBeSent = new EmailNeedsToBeSentIntegrationEvent
            {
                //Body = mailBody,
                IsBodyHtml = true,
                //Subject = "",
                FromEmail   = "*****@*****.**",
                FromName    = "AdminLeads",
                To          = new[] { @event.InqueryHistory.AgentInfo.Email },
                ReplyTo     = @event.InqueryHistory.CustomerInfo.Email,
                AggregateId = @event.InqueryHistory.Id,
                TemplateId  = "c1f08213-6f62-4ba0-8dc2-3d768ae759ee", //Autoresponder for Agent for new Lead. keep it hardcoded for now
                MergeFields = GetMergeField(@event.InqueryHistory.AgentInfo, @event)
            };

            //For now there is no such requirement of informing agent for new lead
            //eventBus.Publish(emailNeedsToBeSent);

            logger.CreateLogger(nameof(@event)).LogTrace($"Inquery history email converted to leads Inquiry history: {@event.InqueryHistory.Id} - Inquiry from: {@event.InqueryHistory.OrganizationInfo.OrganizationEmail}.");
        }
Example #2
0
        public IActionResult SendRentDemoEmail([FromBody] CreateDemoEnquiryEmailCommand @command)
        {
            var emailNeedsToBeSent = new EmailNeedsToBeSentIntegrationEvent
            {
                IsBodyHtml           = @command.IsBodyhtml,
                FromEmail            = @command.From,
                FromName             = "Demo",
                To                   = new[] { @command.To },
                AggregateId          = Guid.NewGuid().ToString(),
                DisableClickTracking = true,
                DisableOpenTracking  = true,
                MergeFields          = GetMergeField(@command),
                TemplateId           = "1797b49e-4c40-43ff-9220-c95816dadd9e"
            };

            _eventBus.Publish(emailNeedsToBeSent);

            return((IActionResult)Ok(emailNeedsToBeSent));
        }
Example #3
0
        public IActionResult SendBuyDemoEmail([FromBody] CreateDemoEnquiryEmailCommand @command)
        {
            var emailNeedsToBeSent = new EmailNeedsToBeSentIntegrationEvent
            {
                IsBodyHtml           = @command.IsBodyhtml,
                FromEmail            = @command.From,
                FromName             = "Demo",
                To                   = new[] { @command.To },
                AggregateId          = Guid.NewGuid().ToString(),
                DisableClickTracking = true,
                DisableOpenTracking  = true,
                MergeFields          = GetMergeField(@command),
                TemplateId           = "770b116f-fe82-410d-b675-198f45361d5a"
            };

            _eventBus.Publish(emailNeedsToBeSent);

            return((IActionResult)Ok(emailNeedsToBeSent));
        }
Example #4
0
        public IActionResult InitZapMailbox(CreateZapierParserMailboxInitilizationEmailCommand @command)
        {
            var emailNeedsToBeSent = new EmailNeedsToBeSentIntegrationEvent
            {
                Body                 = @command.Body,
                IsBodyHtml           = true,
                Subject              = @command.Subject,
                FromEmail            = "*****@*****.**",
                FromName             = "Ilias Hossain",
                To                   = new[] { @command.ToEmail },
                AggregateId          = Guid.NewGuid().ToString(),
                DisableClickTracking = true,
                DisableOpenTracking  = true
            };

            _eventBus.Publish(emailNeedsToBeSent);

            return((IActionResult)Ok(emailNeedsToBeSent));
        }
Example #5
0
        public IActionResult Tracked()
        {
            var aggregateId = Guid.NewGuid().ToString();

            var @event = new AgentInboundEmailTrackedIntegrationEvent()
            {
                Body              = Request.Form["html"],
                PlainText         = Request.Form["plain"],
                OrganizationEmail = Request.Form["envelope[from]"],
                AgentEmail        = Request.Form["envelope[to]"],
                Subject           = $"{Request.Form["headers[Subject]"]}",
                AggregateId       = aggregateId
            };

            if (@event.Subject.Contains(":::::"))
            {
                var usePlainText = @event.Subject.Split(":::::")[2];

                var emailNeedsToBeSent = new EmailNeedsToBeSentIntegrationEvent
                {
                    Body                 = usePlainText.Equals("useplaintext", StringComparison.InvariantCultureIgnoreCase) ? @event.PlainText : @event.Body,
                    IsBodyHtml           = usePlainText.Equals("useplaintext", StringComparison.InvariantCultureIgnoreCase) ? true : false,
                    Subject              = @event.Subject,
                    FromEmail            = "*****@*****.**",
                    FromName             = "Ilias Hossain",
                    To                   = new[] { @event.Subject.Split(":::::")[1] },
                    AggregateId          = Guid.NewGuid().ToString(),
                    DisableClickTracking = true,
                    DisableOpenTracking  = true
                };

                _eventBus.Publish(emailNeedsToBeSent);
            }
            else
            {
                //This  will trigger event in Agent Api to send a autorespondar
                _eventBus.Publish(@event);
            }

            return((IActionResult)Ok(@event));
        }
        public async Task Handle(AgentMarkedAsLaunchedEvent @event, CancellationToken cancellationToken)
        {
            var agentLunchedNotificationTemplate = configuration.GetValue <string>("AgentLunchedNotificationTemplate");

            var emailNeedsToBeSent = new EmailNeedsToBeSentIntegrationEvent
            {
                //Body = mailBody,
                IsBodyHtml = true,
                //Subject = subject,
                FromEmail   = "*****@*****.**",
                FromName    = "AdfenixLeads",
                To          = new[] { @event.Agent.Email },
                ReplyTo     = "*****@*****.**",
                AggregateId = @event.Agent.Id,
                TemplateId  = agentLunchedNotificationTemplate,
                MergeFields = GetMergeField(@event.Agent)
            };

            eventBus.Publish(emailNeedsToBeSent);

            logger.CreateLogger(nameof(@event)).LogTrace($"Agent lunched notification sent {@event.Agent.Id} - {@event.Agent.Email} -templateid {emailNeedsToBeSent.TemplateId}.");
        }
Example #7
0
        public async Task Handle(InqueryHistoryStatusChangedToParsedDomainEvent @event, CancellationToken cancellationToken)
        {
            //msut create some template factory if more inquiry type comes. This is bad approach buy quicker for now
            var customerAutoresponderDefaultTemplateId = configuration.GetValue <string>("CustomerAutoresponderDefaultTemplateIdForBuyInquiry");

            if (@event.InqueryHistory.InquiryType == InquiryType.RentInquiry)
            {
                customerAutoresponderDefaultTemplateId = configuration.GetValue <string>("CustomerAutoresponderDefaultTemplateIdForRentInquiry");
            }

            var emailNeedsToBeSent = new EmailNeedsToBeSentIntegrationEvent
            {
                //Body = mailBody,
                IsBodyHtml = true,
                //Subject = subject,
                FromEmail   = @event.InqueryHistory.AgentEmail,
                FromName    = $"{@event.InqueryHistory.AgentInfo.Firstname} {@event.InqueryHistory.AgentInfo.Lastname}",
                To          = new[] { @event.InqueryHistory.CustomerInfo.Email },
                ReplyTo     = @event.InqueryHistory.AgentInfo.Email,
                AggregateId = @event.InqueryHistory.Id,
                TemplateId  = string.IsNullOrEmpty(@event.InqueryHistory.AgentAutoresponderTemplateInfo?.CustomerAutoresponderTemplateId) ?
                              customerAutoresponderDefaultTemplateId :
                              @event.InqueryHistory.AgentAutoresponderTemplateInfo?.CustomerAutoresponderTemplateId,                       //Autoresponder for agent For new Inquiry. keep it hardcoded for now
                MergeFields = GetMergeField(@event.InqueryHistory.AgentInfo, @event)
            };

            eventBus.Publish(emailNeedsToBeSent);

            var updateCustomerAutoresponderSentCommand = new UpdateCustomerAutoresponderSentCommand()
            {
                AggregateId = @event.InqueryHistory.Id
            };

            await mediator.Send(updateCustomerAutoresponderSentCommand);

            logger.CreateLogger(nameof(@event)).LogTrace($"Autoresponder sent to customer {@event.InqueryHistory.CustomerInfo.Email}- inquiryId: {@event.InqueryHistory.Id}.");
        }