示例#1
0
		protected void Page_Load(object sender, EventArgs e)
		{
			int id;
			if (!int.TryParse(Request.QueryString.Get(PageConstants.LeadIDParam), out id))
				throw new ApplicationException("Cannot find lead");

			_lead = DataManager.GetLeadById(id);
			if(_lead == null)
				throw new ApplicationException("Cannot find lead");
		}
示例#2
0
		public static int SaveLead(Lead entity)
		{
			return _dataProvider.SaveLead(entity);
		}
示例#3
0
		public static void AddLead(Lead entity)
		{
			_dataProvider.SaveLead(entity);
		}
示例#4
0
		public static bool IfLeadIsActive(Lead lead)
		{
			if (lead != null)
			{
				LeadStatus status = GetLeadStatusByID((int)lead.LeadStatus.LeadStatusID);
				return !(status.Status == LeadStatusConstants.Canceled || status.Status == LeadStatusConstants.Completed);
			}
			else
			{
				return false;
			}
		}
示例#5
0
		public static List<ExclusionaryListEntry> SearchInExclusionaryList(Lead suspect)
		{
			List<ExclusionaryListEntry> result = new List<ExclusionaryListEntry>();
			var exclusionaryList = _provider.GetExclusionaryList();
			var nameCheckResult = exclusionaryList
				.Where(e => e.IsIndividual && e.LastName.ToLower() == suspect.LastName.ToLower() &&
				(string.IsNullOrWhiteSpace(suspect.FirstName) || e.FirstName.ToLower() == suspect.FirstName.ToLower()));
			result.AddRange(nameCheckResult);
			var akaCheckResult = exclusionaryList
				.Where(e => 
				{
					if (!e.IsIndividual)
					{
						return false;
					}
					var splittedAka = e.Aka.ToLower().Split(new char[] { ' ', ',', ';', '.' });
					if (!splittedAka.Contains(suspect.LastName.ToLower()))
					{
						return false;
					}
					if (!string.IsNullOrWhiteSpace(suspect.FirstName))
					{
						var splittedName = suspect.FirstName.ToLower().Split(new char[] { ' ', '.' });
						bool isNameMatch = true;
						foreach (string item in splittedName)
						{
							if (!string.IsNullOrWhiteSpace(item) && !splittedAka.Contains(item))
							{
								isNameMatch = false;
								break;
							}
						}
						if (!isNameMatch)
						{
							return false;
						}
					}
					return true;
				});
			result.AddRange(akaCheckResult);
			var companyCheckResult = exclusionaryList
				.Where(c => !c.IsIndividual &&
				(!string.IsNullOrWhiteSpace(suspect.CompanyName) && c.CompanyName.ToLower() == suspect.CompanyName.ToLower()) ||
				(!string.IsNullOrWhiteSpace(suspect.CompanyName) && c.Aka.ToLower() == suspect.CompanyName.ToLower()));
			result.AddRange(companyCheckResult);
			result.AddRange(CompareExclListAddress(exclusionaryList, suspect.CompanyAddress));
			result.AddRange(CompareExclListAddress(exclusionaryList, suspect.HomeAddress));
			result.AddRange(CompareExclListAddress(exclusionaryList, suspect.WorkAddress));
			result.AddRange(CompareExclListAddress(exclusionaryList, suspect.SubjectPropertyAddress));

			if (result.Count == 0)
			{
				return null;
			}
			return result;
		}
示例#6
0
		public static sdnListSdnEntry[] SearchInSDN(Lead suspect)
		{
			string firstName = suspect.FirstName;
			string lastName = suspect.LastName;
			List<sdnListSdnEntry> result = new List<sdnListSdnEntry>();
			sdnList sdn = GetSDN();
			foreach (var entry in sdn.sdnEntry)
			{
				bool isFirstNameMatch = false;
				bool isLastNameMatch = false;
				if (string.IsNullOrWhiteSpace(entry.firstName) || (entry.firstName.ToLower().Equals(firstName.ToLower())))
				{
					isFirstNameMatch = true;
				}
				if (!string.IsNullOrWhiteSpace(entry.lastName) && entry.lastName.ToLower().Equals(lastName.ToLower()))
				{
					isLastNameMatch = true;
				}
				if (!string.IsNullOrWhiteSpace(suspect.CompanyName) && entry.lastName.ToLower().Equals(suspect.CompanyName.ToLower()))
				{
					isLastNameMatch = true;
				}
				if (isFirstNameMatch && isLastNameMatch)
				{
					result.Add(entry);
					continue;
				}
				if (entry.akaList != null)
				{
					foreach (var akaEntry in entry.akaList)
					{
						isFirstNameMatch = false;
						isLastNameMatch = false;
						if (string.IsNullOrWhiteSpace(akaEntry.firstName) || (akaEntry.firstName.ToLower().Equals(firstName.ToLower())))
						{
							isFirstNameMatch = true;
						}
						if (!string.IsNullOrWhiteSpace(entry.lastName) && akaEntry.lastName.ToLower().Equals(lastName.ToLower()))
						{
							isLastNameMatch = true;
						}
						if (!string.IsNullOrWhiteSpace(suspect.CompanyName) && akaEntry.lastName.ToLower().Equals(suspect.CompanyName.ToLower()))
						{
							isLastNameMatch = true;
						}
						if (isFirstNameMatch && isLastNameMatch)
						{
							result.Add(entry);
							break;
						}
					}
				}
				if (entry.addressList != null)
				{
					foreach (var addressEntry in entry.addressList)
					{
						if (CompareSDNAddress(addressEntry, suspect.HomeAddress) ||
							(CompareSDNAddress(addressEntry, suspect.CompanyAddress)) ||
							(CompareSDNAddress(addressEntry, suspect.SubjectPropertyAddress)) ||
							(CompareSDNAddress(addressEntry, suspect.WorkAddress)))
						{
							result.Add(entry);
							break;
						}
					}
				}
			}
			if (result.Count == 0)
			{
				return null;
			}
			return result.ToArray();
		}
示例#7
0
		public int SaveExcList(int validationID, Lead lead, string status)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				//int statusPassed = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusPassed)
				//  .Select(st => st.StatusID)
				//  .First();
				//int statusFailed = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusFailed)
				//  .Select(st => st.StatusID)
				//  .First();
				//int statusNoInfo = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusNoInformation)
				//  .Select(st => st.StatusID)
				//  .First();

				int exRes = 0;
				T_ValidationResult tResult = new T_ValidationResult();
				T_ValidationFail tExcListValidation = new T_ValidationFail();
				LeadValidationManager tLeadVM = new LeadValidationManager();



				tResult.ValidationID = validationID;
				tResult.TypeID = dc.T_ValidationTypes
					.Where(t => t.vtDescription == ValidationConstants.FreddieList)
					.Select(tp => tp.TypeID)
					.First();

				if (status != ValidationConstants.StatusNoInformation)
				{
					var validResult = LeadValidationManager.SearchInExclusionaryList(lead);
					if (validResult != null)
					{
						exRes = (int)StatusValidation.Failed;
						tExcListValidation.vfExcList = tLeadVM.GetXmlExcListEntry(validResult);

						dc.T_ValidationFails.InsertOnSubmit(tExcListValidation);
						dc.SubmitChanges();
						tResult.StatusID = (int)StatusValidation.Failed;
						tResult.FailID = tExcListValidation.FailID;
						//---------------
					}
					else
					{
						exRes = (int)StatusValidation.Passed;
						tResult.StatusID = (int)StatusValidation.Passed;
						tResult.FailID = null;
					}
				}
				else
				{
					exRes = (int)StatusValidation.NoInformation;
					tResult.StatusID = (int)StatusValidation.NoInformation;
					tResult.FailID = null;
				}

				dc.T_ValidationResults.InsertOnSubmit(tResult);
				dc.SubmitChanges();
				return exRes;
			}
		}
示例#8
0
		public int SaveAddrValidation(int validationID, Lead lead, string status)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{

				int addrValStatus = 0;
				int addressID;
				T_ValidationResult tResult = new T_ValidationResult();
				T_ValidationAddress tAddress = new T_ValidationAddress();
				T_ValidationAddressError tError = new T_ValidationAddressError();

				tResult.ValidationID = validationID;
				tResult.TypeID = (int)TypeValidation.AddressValidation;
				if (status != ValidationConstants.StatusNoInformation)
				{
					var validAddress = LeadValidationManager.GetValidAddress(lead.SubjectPropertyAddress);
					if (validAddress.Error != null)
					{
						int errorID;
						ValidationAddressError error = new ValidationAddressError();
						error.Description = validAddress.Error.Description;
						error.Location = validAddress.Error.Location;
						error.Number = validAddress.Error.Number;
						errorID = SaveValidationAddressError(error);
						addrValStatus = (int)StatusValidation.Failed;
						tAddress.ErrorID = errorID;
					}
					else
					{
						//			SaveValidationAddress(validAddress);
						bool isCorrect = LeadValidationManager.CompareAddresses(lead.SubjectPropertyAddress, validAddress);
						if (isCorrect)
						{
							addrValStatus = (int)StatusValidation.Passed;
						}
						else
						{
							addrValStatus = (int)StatusValidation.Error;
						}
					}
					addressID = SaveValidationAddress(validAddress);
					tResult.AddressID = addressID;
					tResult.StatusID = addrValStatus;
				}
				else
				{
					addrValStatus = (int)StatusValidation.NoInformation;
					tResult.StatusID = addrValStatus;
				}
				dc.T_ValidationResults.InsertOnSubmit(tResult);
				dc.SubmitChanges();
				return addrValStatus;
			}
		}
示例#9
0
		public int SaveOFAC(int validationID, Lead lead, string status)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				//int statusPassed = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusPassed)
				//  .Select(st => st.StatusID)
				//  .First();
				//int statusFailed = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusFailed)
				//  .Select(st => st.StatusID)
				//  .First();
				//int statusNoInfo = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusNoInformation)
				//  .Select(st => st.StatusID)
				//  .First();

				T_ValidationResult tResult = new T_ValidationResult();
				LeadValidationManager tLeadVM = new LeadValidationManager();
				T_ValidationFail tFail = new T_ValidationFail();
				//T_Lead tLead = new T_Lead();

				tResult.ValidationID = validationID;
				tResult.TypeID = dc.T_ValidationTypes
					.Where(t => t.vtDescription == ValidationConstants.OFAC).Select(tp => tp.TypeID).First();

				int validStat = 0;
				if (status != ValidationConstants.StatusNoInformation)
				{
					var resultSearchInPLC = LeadValidationManager.SearchInPLC(lead);
					var resultSearchInSDN = LeadValidationManager.SearchInSDN(lead);

					if (resultSearchInPLC == null && resultSearchInSDN == null)
					{
						validStat = (int)StatusValidation.Passed;
						tResult.FailID = null;
					}
					else
					{
						if (resultSearchInPLC != null)
						{
							tFail.vfPLC = tLeadVM.GetXmlPLC(resultSearchInPLC);
						}
						if (resultSearchInSDN != null)
						{
							tFail.vfSDN = tLeadVM.GetXmlSDN(resultSearchInSDN);
						}
						dc.T_ValidationFails.InsertOnSubmit(tFail);
						dc.SubmitChanges();
						tResult.FailID = tFail.FailID;
						validStat = (int)StatusValidation.Failed;
					}
				}
				else
				{
					validStat = (int)StatusValidation.NoInformation;
					tResult.FailID = null;
				}



				//  if (resultSearchInPLC != null || resultSearchInSDN != null)
				//  {
				//    if (resultSearchInPLC != null)
				//    {
				//      tFail.vfPLC = tLeadVM.GetXmlPLC(resultSearchInPLC);
				//    }
				//    if (resultSearchInSDN != null)
				//    {
				//      tFail.vfSDN = tLeadVM.GetXmlSDN(resultSearchInSDN);

				//    }
				//    dc.T_ValidationFails.InsertOnSubmit(tFail);
				//    dc.SubmitChanges();
				//    tResult.FailID = tFail.FailID;
				//  }

				//  if (resultSearchInPLC == null && resultSearchInSDN == null)
				//  {
				//    validStat = (int)StatusValidation.Passed;
				//    tResult.FailID = null;
				//    //
				//  }
				//  else
				//  {
				//    validStat = (int)StatusValidation.Failed;
				//  }

				//}
				//else
				//{
				//  validStat = (int)StatusValidation.NoInformation;
				//  tResult.FailID = null;
				//}

				tResult.StatusID = validStat;
				dc.T_ValidationResults.InsertOnSubmit(tResult);
				dc.SubmitChanges();

				return validStat;
			}
		}
示例#10
0
		//private Address GetAddress(string country, string state, string city, string street, string zipCode)
		//{
		//  if (country == String.Empty && state == String.Empty && city == String.Empty && street == String.Empty && zipCode == String.Empty)
		//  {
		//    return null;
		//  }
		//  Address address = new Address
		//  {
		//    Country = new Country(){ Name=country},
		//    State = state,
		//    City = city,
		//    Street = street,
		//    ZipCode = zipCode
		//  };
		//  return address;
		//}

		protected void btnSave_Click(object sender, EventArgs e)
		{
			if (string.IsNullOrEmpty(txtBusinessPhone.Text) && string.IsNullOrEmpty(txtHomePhone.Text) && string.IsNullOrEmpty(txtMobilePhone.Text) && string.IsNullOrEmpty(txtEmail.Text) && string.IsNullOrEmpty(txtSkype.Text) && string.IsNullOrEmpty(txtFax.Text))
			{
				txtContactsValidation.Text = "At least one Contact information field is required.";
				return;
			}
			else
			{
				txtContactsValidation.Text = "";
			}

			LeadStatus leadStatus = DataManager.GetLeadStatusByID(int.Parse(ddlStatus.SelectedValue));
			LeadSource leadSource = null;
			var sId = int.Parse(ddlSource.SelectedValue);
			if (sId != -1)
			{
				leadSource = DataManager.GetLeadSourceByID(sId);
			}
			MembershipUser user = Membership.GetUser(ddlOwner.SelectedValue);
			Guid owner = (Guid)user.ProviderUserKey;

			if (Request.QueryString[PageConstants.LeadIDParam] != null)
			{
				int id = int.Parse(Request.QueryString[PageConstants.LeadIDParam]);
				var currentLead = DataManager.GetLeadById(id);
				if (currentLead.Owner != owner)
				{
					var path = VirtualPathUtility.ToAbsolute("~/");
					NotificationManager.AssignNotify(owner, currentLead.Owner, id, path);
				}
			}


			int? leadId = null;
			if (Request.QueryString[PageConstants.LeadIDParam] != null)
			{
				leadId = int.Parse(Request.QueryString[PageConstants.LeadIDParam]);
			}

			int salutId = int.Parse(ddlSalutation.SelectedValue);
			string salutName = null;
			if (salutId != -1)
			{
				salutName = DataManager.GetSalutationNameById(salutId);
			}

			Lead lead = new Lead
			{
				Topic = txtTopic.Text,
				CreatedOn = DateTime.Now,
				BusinessPhone = txtBusinessPhone.Text,
				MobilePhone = txtMobilePhone.Text,
				CompanyAddress = ucZipCompany.Address,
				CompanyName = txtCompanyName.Text,
				Email = txtEmail.Text,
				FirstName = txtFirstName.Text,
				HomeAddress = ucZipHome.Address,
				HomePhone = txtHomePhone.Text,
				Honorific = salutName,
				JobTitle = txtJobTitle.Text,
				LastName = txtLastName.Text,
				WorkAddress = ucZipWork.Address,
				LeadStatus = leadStatus,
				LeadSource = leadSource,
				Owner = owner,
				LeadID = leadId,
				Fax = txtFax.Text,
				Skype = txtSkype.Text,
				SSN = txtSSN.Text,
				SubjectPropertyAddress = ucZipSPA.Address,
				AddrVal = (int)StatusValidation.NoInformation,
				ExlList = (int)StatusValidation.NoInformation,
				OFAC = (int)StatusValidation.NoInformation,
				Contact = new ContactPreferences
				{
					IsAllowBusinessPhone = SaveRadioSelect(rblBusinessPhone.SelectedValue),
					IsAllowEmail = SaveRadioSelect(rblEmail.SelectedValue),
					IsAllowFax = SaveRadioSelect(rblFax.SelectedValue),
					IsAllowHomePhone = SaveRadioSelect(rblHomePhone.SelectedValue),
					IsAllowMobilePhone = SaveRadioSelect(rblMobilePhone.SelectedValue),
					IsAllowSkype = SaveRadioSelect(rblSkype.SelectedValue),
					PreferredContact = ddlPreferred.SelectedValue
				}
			};
			if (!string.IsNullOrWhiteSpace(txtNewNote.Text))
			{
				Note newNote = new Note() { Created = DateTime.Now, Text = txtNewNote.Text };
				lead.Notes = new System.Collections.Generic.List<Note>();
				lead.Notes.Add(newNote);
			}
			lead.LeadID = DataManager.SaveLead(lead);

            DataManager.LeadModified(lead.LeadID.Value);

			if (Request.QueryString[PageConstants.LeadIDParam] == null)
			{
				var path = VirtualPathUtility.ToAbsolute("~/");
				NotificationManager.AssignNotify(owner, null, Convert.ToInt32(lead.LeadID), path);
			}
			//add logic to create important date
			if (txtAddDate.Text.Length != 0)
			{
				ImportantDate impDate = new ImportantDate();
				impDate.Note = txtDateNote.Text;
				impDate.Reason = txtReason.Text;

				DateTime dtResult = new DateTime();
				Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");

				if (DateTime.TryParse(txtAddDate.Text, out dtResult))
				{
					impDate.Date = dtResult;
					DataManager.SaveImportantDate(impDate, (int)lead.LeadID);
				}

			}
			//
			//tcEditLead.Visible = false;
			btnSave.Visible = false;
			Response.Redirect(PageConstants.LeadPipeLinePage);
		}
示例#11
0
		internal Lead GetLeadEntity(T_Lead tLead)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				Lead lead = new Lead();
				lead.LeadID = tLead.LeadID;

				lead.Owner = tLead.OwnerID;
				if (tLead.T_LeadSource != null)
				{
					lead.LeadSource = new LeadSource { LeadSourceID = tLead.LeadSourceID, Where = tLead.T_LeadSource.lsrcWhere };
				}
				lead.LeadStatus = new LeadStatus { LeadStatusID = tLead.T_LeadStatus.LeadStatusID, Status = tLead.T_LeadStatus.lstsStatus };
				lead.FirstName = tLead.ldFirstName;
				lead.Honorific = GetLeadSalutation(tLead.LeadID);
				lead.LastName = tLead.ldLastName;
				lead.BusinessPhone = tLead.ldBusinessPhone;
				lead.HomePhone = tLead.ldHomePhone;
				lead.MobilePhone = tLead.ldMobilePhone;
				lead.Email = tLead.ldEmail;
				lead.Skype = tLead.ldSkype;
				lead.JobTitle = tLead.ldJobTitle;
				lead.CompanyName = tLead.ldCompanyName;
				lead.CreatedOn = tLead.ldCreatedOn;
				lead.Topic = tLead.ldTopic;
				lead.OFAC = tLead.ldOFAC;
				lead.ExlList = tLead.ldExlList;
				lead.AddrVal = tLead.ldAddrVal;

				lead.SSN = tLead.ldSSN;
				lead.Fax = tLead.ldFax;
				lead.Contact = new ContactPreferences
				{
					IsAllowBusinessPhone = tLead.T_AllowedContact.acBusinessPhone,
					IsAllowEmail = tLead.T_AllowedContact.acEmail,
					IsAllowFax = tLead.T_AllowedContact.acFax,
					IsAllowHomePhone = tLead.T_AllowedContact.acHomePhone,
					IsAllowMobilePhone = tLead.T_AllowedContact.acCellPhone,
					IsAllowSkype = tLead.T_AllowedContact.acSkypeName,
					PreferredContact = tLead.T_AllowedContact.acPreferredContact
				};
				int leadNumber;
				if (!int.TryParse(tLead.ldNumber, out leadNumber))
				{
					leadNumber = 1000000;
				}
				lead.Number = leadNumber;
				var tAddress = dc.T_Addresses.Where(a => a.AddressID == tLead.CompanyAddressID);
				if (tAddress.Count() != 0)
				{
					lead.CompanyAddress = GetAddressEntity(tAddress.First());
				}
				tAddress = dc.T_Addresses.Where(a => a.AddressID == tLead.HomeAddressID);
				if (tAddress.Count() != 0)
				{
					lead.HomeAddress = GetAddressEntity(tAddress.First());
				}
				tAddress = dc.T_Addresses.Where(a => a.AddressID == tLead.WorkAddressID);
				if (tAddress.Count() != 0)
				{
					lead.WorkAddress = GetAddressEntity(tAddress.First());
				}
				tAddress = dc.T_Addresses.Where(a => a.AddressID == tLead.SubjectPropertyAddressID);
				if (tAddress.Count() != 0)
				{
					lead.SubjectPropertyAddress = GetAddressEntity(tAddress.First());
				}

				var tLeadNotes = dc.T_LeadNotes.Where(n => n.LeadID == tLead.LeadID);
				lead.Notes = new List<Note>();
				foreach (var tLeadNote in tLeadNotes)
				{
					lead.Notes.Add(GetNoteEntity(tLeadNote.T_Note));
				}
				//add logic to get important dates
				var tLeadDates = dc.T_LeadImportantDates.Where(d => d.LeadID == tLead.LeadID);
				lead.Dates = new List<ImportantDate>();
				foreach (var tLeadDate in tLeadDates)
				{
					lead.Dates.Add(GetImportantDateEntity(tLeadDate.T_ImportantDate));
				}

				return lead;
			}
		}
示例#12
0
		public int SaveLead(Lead entity)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_Lead tLead;
				if (!entity.LeadID.HasValue)
				{
					tLead = new T_Lead();
					dc.T_Leads.InsertOnSubmit(tLead);
				}
				else
				{
					tLead = dc.T_Leads.SingleOrDefault(l => l.LeadID == entity.LeadID);
					if (tLead == null)
					{
						throw new ApplicationException("Lead not found");
					}
				}
				tLead.ldBusinessPhone = entity.BusinessPhone;
				tLead.ldCompanyName = entity.CompanyName;
				tLead.ldEmail = entity.Email;
				tLead.ldFirstName = entity.FirstName;
				tLead.ldHomePhone = entity.HomePhone;
				tLead.ldJobTitle = entity.JobTitle;
				tLead.ldLastName = entity.LastName;
				tLead.ldMobilePhone = entity.MobilePhone;
				tLead.ldSkype = entity.Skype;
				//if (entity.OFAC > 0 && entity.OFAC < 5)
				//{
				tLead.ldOFAC = entity.OFAC;
				//}
				//if (tLead.ldExlList > 0 && tLead.ldExlList < 5)
				//{
				tLead.ldExlList = entity.ExlList;
				//}
				//if (entity.AddrVal > 0 && entity.AddrVal < 5)
				//{
				tLead.ldAddrVal = entity.AddrVal;
				//}


				tLead.ldSSN = entity.SSN;
				tLead.ldFax = entity.Fax;

				//SaveContactPreferences(entity.Contact, tLead.LeadID);

				if (!entity.LeadID.HasValue)
				{
					var lastNumber = GetLastNumber();
					tLead.ldNumber = (lastNumber + 1).ToString();
					entity.Number = lastNumber + 1;
					IncrementLastNumber();
				}

				if (entity.Honorific != null)
				{
					tLead.SalutationID = GetSalutationIdByName(entity.Honorific);
				}
				else
				{
					tLead.SalutationID = null;
				}
				tLead.OwnerID = entity.Owner;
				tLead.ldTopic = entity.Topic;
				tLead.ldCreatedOn = entity.CreatedOn;
				tLead.LeadStatusID = (int)entity.LeadStatus.LeadStatusID;
				if (entity.LeadSource != null)
				{
					tLead.LeadSourceID = entity.LeadSource.LeadSourceID;
				}
				if (entity.CompanyAddress != null)
				{
					tLead.CompanyAddressID = SaveAddress(entity.CompanyAddress);
				}
				if (entity.HomeAddress != null)
				{
					tLead.HomeAddressID = SaveAddress(entity.HomeAddress);
				}
				if (entity.WorkAddress != null)
				{
					tLead.WorkAddressID = SaveAddress(entity.WorkAddress);
				}
				if (entity.SubjectPropertyAddress != null)
				{
					tLead.SubjectPropertyAddressID = SaveAddress(entity.SubjectPropertyAddress);
				}
				dc.SubmitChanges();
				//remove this code from line 58
				SaveContactPreferences(entity.Contact, tLead.LeadID);
				if (entity.Notes != null)
				{
					foreach (Note item in entity.Notes)
					{
						if (!item.NoteID.HasValue)
						{
							item.NoteID = SaveNote(item, tLead.LeadID);
						}
						else
						{
							T_Note tNote = dc.T_Notes.Single(n => n.NoteID == item.NoteID);
							if (tNote.ntEdited < item.Edited)
							{
								SaveNote(item, tLead.LeadID);
							}
						}
					}
				}
				//add logic to save important dates
				if (entity.Dates != null)
				{
					foreach (ImportantDate date in entity.Dates)
					{
						if (!date.DateID.HasValue)
							date.DateID = SaveImportantDate(date, tLead.LeadID);
						else
						{
							//T_ImportantDate tDate = dc.T_ImportantDates.SingleOrDefault(d => d.DateID == date.DateID);
						}

					}
				}

				return tLead.LeadID;
			}
		}
示例#13
0
		public List<Lead> GetLeads()
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				List<Lead> list = new List<Lead>();
				var query = dc.T_Leads.AsQueryable();
				foreach (var item in query)
				{
					Lead lead = new Lead();
					lead = GetLeadEntity(item);
					list.Add(lead);
				}
				return list;
			}
		}
示例#14
0
        protected int ValidateLead(Lead lead, UserInformation userInfo)
        {
            ValidationLead validation = new ValidationLead();
            validation.Lead = lead;
            validation.User = userInfo;

            List<ValidationResult> listResults = new List<ValidationResult>();

            bool ofac = true;
            bool freddie = true;

            var results = LeadValidationManager.CheckValidationsSource();
            foreach (var item in results)
            {
                switch (item.Type.Type)
                {
                    case ValidationConstants.OFAC:
                        if (item.Status.Status == ValidationConstants.StatusError)
                        {
                            ofac = false;
                        }

                        break;
                    case ValidationConstants.FreddieList:
                        if (item.Status.Status == ValidationConstants.StatusError)
                        {
                            freddie = false;
                        }
                        break;
                    default:
                        break;
                }
            }

            var typeOFAC = new ValidationType();
            var statusOFAC = new ValidationStatus();

            var typeAddress = new ValidationType();
            var statusAddress = new ValidationStatus();

            var typeFreddie = new ValidationType();
            var statusFreddie = new ValidationStatus();

            typeOFAC.Type = ValidationConstants.OFAC;
            if (ofac)
            {
                statusOFAC.Status = ValidationConstants.StatusPassed;
            }
            else
            {
                statusOFAC.Status = ValidationConstants.StatusNoInformation;
            }
            listResults.Add(new ValidationResult { Type = typeOFAC, Status = statusOFAC });


            typeFreddie.Type = ValidationConstants.FreddieList;
            if (freddie)
            {
                statusFreddie.Status = ValidationConstants.StatusPassed;
            }
            else
            {
                statusFreddie.Status = ValidationConstants.StatusNoInformation;
            }
            listResults.Add(new ValidationResult { Type = typeFreddie, Status = statusFreddie });


            typeAddress.Type = ValidationConstants.Address;
            statusAddress.Status = ValidationConstants.StatusNoInformation;
            listResults.Add(new ValidationResult { Type = typeAddress, Status = statusAddress });

            validation.Results = listResults;

            return LeadValidationManager.SaveValidationLead(validation);

        }