internal static string BuildHealthURL(CommonLead cmnLead, HealthLead prodLead, MatchBuyer matchBuyer) { //Product-Specific Fields var obj = new { affiliate_campaign_id = 419, vmform_hash = "3E008", vmform_ip = cmnLead.IpAddress.Trim(), vmform_referer = "https://www.tophealthinsuranceplan.co.uk", vmform_siteid = 1732, vmform_source = "ppcsearch", cover_for = GetHealthCover(prodLead.CoverTypeId), gender = cmnLead.Title == "Mr" ? "Male" : "Female", current_policy = prodLead.ExistingPolicy ? "yes_myself" : "no", smoker = prodLead.Smoker ? "Yes" : "No", first_name = cmnLead.FirstName.Trim(), last_name = cmnLead.LastName.Trim(), address_line_1 = cmnLead.Address, postcode = cmnLead.PostCode, dob = prodLead.DOB.ToString("dd-MM-yyyy"), telephone = cmnLead.HomePhone.Trim(), mobile = cmnLead.WorkPhone.Trim(), email = cmnLead.Email.Trim() }; string queryString = UtilityMethods.GetQueryString(obj); return(queryString); }
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()); }
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); }
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))); } }
public ActionResult Index(HealthFilterLeadModel 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); } model.Dob = Dob; model.Age = CalculateAge(Dob); HealthLead healthLead = new HealthLead() { CoverTypeId = model.CoverType, FamilyNumber = model.TotalPerson, ExistingPolicy = model.ExistingPolicy,// default Value Smoker = model.Smoker, Title = model.YourTitle, FirstName = model.FirstName, LastName = model.LastName, Dob = Dob, Age = CalculateAge(Dob), HomePhone = model.HomePhone, WorkPhone = model.WorkPhone ?? model.HomePhone, Email = model.Email, Address = model.Address, City = model.City ?? string.Empty, PostCode = model.PostCode, GeneratedDateTime = DateTime.Now, Status = "NEW", SiteId = 3, ProductName = "Health", Source = Session["Source"] as string ?? null, Keyword = Session["Keyword"] as string ?? null, MatchType = Session["Match"] as string ?? null, IpAddress = Session["RemoteIPAddress"] as string ?? null }; //var id = _captureService.NewAdminLeadCapture(healthLead, "http://localhost:3431/dataConverstion/capture"); var id = _captureService.NewAdminLeadCapture(healthLead, "https://api.websearchmedia.co.uk/dataConverstion/capture"); // var id = _captureService.NewAdminLeadCapture(lead, ""); if (id > 0) { TempData["LeadId"] = id; } else { return(View(model)); } ThankModel thank = new ThankModel() { FirstName = model.FirstName, LastName = model.LastName, Title = model.YourTitle }; return(RedirectToAction("Thank", "Home", thank)); } return(View(model)); }