Beispiel #1
0
        public IHttpActionResult CaptureLead(AllFieldCapture lead)
        {
            try
            {
                string prodName = UtilityMethods.GetProductName(lead.ProductName);

                CommonLead cmnLead = Mapper.Map <CommonLead>(lead);
                if (cmnLead.FirstName.Contains("test") || cmnLead.LastName.Contains("test") || cmnLead.FirstName.ToLower().Contains("test"))
                {
                    cmnLead.Status = EntityObjects.Enaum.LeadType.test;
                }
                _dbContext.CommonLeads.Add(cmnLead);
                _dbContext.SaveChanges();
                if (prodName == GlobalConstant.Life)
                {
                    LifeLead lifeLead = Mapper.Map <LifeLead>(lead);
                    lifeLead.CommonLeadId = cmnLead.Id;
                    _dbContext.LifeLeads.Add(lifeLead);
                }
                else if (prodName == GlobalConstant.Funeral)
                {
                    FuneralLead funeralLead = Mapper.Map <FuneralLead>(lead);
                    funeralLead.CommonLeadId = cmnLead.Id;
                    _dbContext.FuneralLeads.Add(funeralLead);
                }
                else if (prodName == GlobalConstant.Health)
                {
                    HealthLead healthLead = Mapper.Map <HealthLead>(lead);
                    healthLead.CommonLeadId = cmnLead.Id;
                    _dbContext.HealthLeads.Add(healthLead);
                }
                else if (prodName == GlobalConstant.CorporateHealth)
                {
                    CorporateHealthLead corporateHealthLead = Mapper.Map <CorporateHealthLead>(lead);
                    corporateHealthLead.CommonLeadId = cmnLead.Id;
                    _dbContext.CorporateHealthLeads.Add(corporateHealthLead);
                }
                _dbContext.SaveChanges();
                if (cmnLead.FirstName.Contains("test"))
                {
                    return(Ok(new { result = "success", ref_id = cmnLead.Id }));
                }
                if (cmnLead.FirstName.Contains("Test"))
                {
                    return(Ok(new { result = "success", ref_id = cmnLead.Id }));
                }

                LeadTransfer(cmnLead.Id);

                return(Ok(new { result = "success", ref_id = cmnLead.Id }));
            }
            catch (Exception ex)
            {
                return(BadRequest("faild"));
            }
            return(Ok());
        }
Beispiel #2
0
        internal static TransferLog SendXML(CommonLead cmnLead, MatchBuyer matchBuyer)
        {
            TransferLog tLog = null;
            DateTime    generatedDateTime = new DateTime();
            string      serverPost        = "";

            if (cmnLead.ProductName.Equals(GlobalConstant.Life))//Life
            {
                LifeLead prodLead = UtilityMethods.GetProductLeadByLeadId <LifeLead>(cmnLead.Id, cmnLead.ProductName);
                generatedDateTime = DateTime.Now;
                serverPost        = BuildLifeURL(cmnLead, prodLead, matchBuyer);
            }
            else if (cmnLead.ProductName.Equals(GlobalConstant.Funeral))// funeral
            {
                FuneralLead prodLead = UtilityMethods.GetProductLeadByLeadId <FuneralLead>(cmnLead.Id, cmnLead.ProductName);
                generatedDateTime = DateTime.Now;
                serverPost        = BuildFuneralURL(cmnLead, prodLead, matchBuyer);
            }
            else if (cmnLead.ProductName.Equals(GlobalConstant.Health))// Health
            {
                HealthLead prodLead = UtilityMethods.GetProductLeadByLeadId <HealthLead>(cmnLead.Id, cmnLead.ProductName);
                generatedDateTime = DateTime.Now;
                serverPost        = BuildHealthURL(cmnLead, prodLead, matchBuyer);
            }
            else if (cmnLead.ProductName.Equals(GlobalConstant.CorporateHealth))//Corporate Health
            {
                CorporateHealthLead prodLead = UtilityMethods.GetProductLeadByLeadId <CorporateHealthLead>(cmnLead.Id, cmnLead.ProductName);
                generatedDateTime = DateTime.Now;
                serverPost        = BuildaCorporateHealthURL(cmnLead, prodLead, matchBuyer);
            }
            if (serverPost != "")
            {
                tLog = SendResponse(cmnLead.Id, generatedDateTime, serverPost, matchBuyer);
                // Send text to customer and buyer after successful transferred

                return(tLog);
            }

            return(null);
        }
Beispiel #3
0
        internal static string BuildFuneralURL(CommonLead cmnLead, FuneralLead prodLead, MatchBuyer matchbuyer)
        {
            var obj = new
            {
                affiliate_campaign_id = 325,
                vmform_hash           = "2EAEE",
                vmform_ip             = cmnLead.IpAddress,
                vmform_referer        = "https://topfuneralplan.co.uk",
                vmform_siteid         = 1517,
                vmform_source         = "ppcsearch",

                first_name     = cmnLead.FirstName,
                last_name      = cmnLead.LastName,
                address_line_1 = cmnLead.Address,
                postcode       = cmnLead.PostCode,
                dob            = prodLead.DOB.ToString("dd-MM-yyyy"),
                telephone      = cmnLead.HomePhone,
                email          = cmnLead.Email
            };
            string queryString = UtilityMethods.GetQueryString(obj);

            return(queryString);
        }
Beispiel #4
0
        public static T GetProductLeadByLeadId <T>(int leadId, string parentProductName) where T : class
        {
            using (var context = new EFDbContext())
            {
                if (parentProductName == GlobalConstant.Life)
                {
                    LifeLead prodLead = context.LifeLeads.FirstOrDefault(x => x.CommonLeadId == leadId);
                    return((T)Convert.ChangeType(prodLead, typeof(T)));
                }
                else if (parentProductName.Equals(GlobalConstant.Funeral))
                {
                    FuneralLead prodLead = context.FuneralLeads.FirstOrDefault(x => x.CommonLeadId == leadId);
                    return((T)Convert.ChangeType(prodLead, typeof(T)));
                }
                else if (parentProductName.Equals(GlobalConstant.Health))
                {
                    HealthLead prodLead = context.HealthLeads.FirstOrDefault(x => x.CommonLeadId == leadId);
                    return((T)Convert.ChangeType(prodLead, typeof(T)));
                }

                //should add other product
                return((T)Convert.ChangeType(null, typeof(T)));
            }
        }
Beispiel #5
0
        public ActionResult Index(FilterModel model)
        {
            if (ModelState.IsValid)
            {
                var Dob = DateTime.Parse(SqlDateTime.MinValue.ToString());
                if (model.Day != 0 && model.Month != 0 && model.Year != 0)
                {
                    var daysOfMonth = DateTime.DaysInMonth(model.Year, model.Month);
                    if (daysOfMonth < model.Day)
                    {
                        model.Day = daysOfMonth;
                    }
                    Dob = new DateTime(model.Year, model.Month, model.Day);
                }
                FuneralLead lead = new FuneralLead()
                {
                    Address           = model.Address,
                    City              = string.Empty,
                    Email             = model.Email,
                    FirstName         = model.FirstName,
                    GeneratedDateTime = DateTime.Now,
                    HomePhone         = model.HomePhone,
                    Source            = Session["Source"] as string ?? null,
                    Keyword           = Session["Keyword"] as string ?? null,
                    MatchType         = Session["Match"] as string ?? null,
                    IpAddress         = Session["RemoteIPAddress"] as string ?? null,
                    LastName          = model.LastName,
                    PostCode          = model.PostCode,
                    ProductName       = "Funeral",
                    SiteId            = 2,
                    Status            = "New",
                    Title             = model.Title,
                    WorkPhone         = model.HomePhone ?? model.WorkPhone,


                    DOB = Dob,
                    Age = CalculateAge(Dob)
                };

                // var id = _captureService.NewAdminLeadCapture(lead, "http://localhost:3431/dataConverstion/capture");

                var id = _captureService.NewAdminLeadCapture(lead, "https://api.websearchmedia.co.uk/dataConverstion/capture");
                //  var id = _captureService.NewAdminLeadCapture(lead, "");
                if (id > 0)
                {
                    TempData["LeadId"] = id;
                }
                else
                {
                }
                ThankModel tmodel = new ThankModel()
                {
                    Title     = model.Title,
                    FirstName = model.FirstName,
                    LastName  = model.LastName
                };
                TempData["thank"] = tmodel;

                return(RedirectToAction("Index", "Thank"));
            }
            return(View());
        }