partial void DeleteT_Lead(T_Lead instance);
partial void InsertT_Lead(T_Lead instance);
partial void UpdateT_Lead(T_Lead instance);
private void attach_T_Leads1(T_Lead entity) { this.SendPropertyChanging(); entity.T_ValidationStatus1 = this; }
private void detach_T_Leads2(T_Lead entity) { this.SendPropertyChanging(); entity.T_ValidationStatus2 = null; }
private void attach_T_Leads(T_Lead entity) { this.SendPropertyChanging(); entity.T_LeadStatus = this; }
private void detach_T_Leads(T_Lead entity) { this.SendPropertyChanging(); entity.T_LeadStatus = null; }
private void detach_T_Leads3(T_Lead entity) { this.SendPropertyChanging(); entity.T_Address3 = null; }
private void attach_T_Leads2(T_Lead entity) { this.SendPropertyChanging(); entity.T_Address2 = this; }
/// <summary> /// This version support only /// </summary> public int GetLeadIdByActivityId(int id) { var activityLead = new T_ActivityLead(); var lead = new T_Lead(); using (var dc = new EngageCCTDataClassesDataContext()) { activityLead = dc.T_ActivityLeads.Where(a => a.ActivityID == id).FirstOrDefault(); try { lead = dc.T_Leads.Where(l => l.LeadID == activityLead.LeadID).FirstOrDefault(); } catch (NullReferenceException e) { var exc = new Exception("No such activity in DB", e); throw exc; } } if (lead == null) { var exc = new Exception("No such lead in DB"); throw exc; } else { return lead.LeadID; } //return _dataLeadProvider.GetLeadSalutation(lead.SalutationID) + " " + lead.ldFirstName + " " + lead.ldLastName + "(Id: " + lead.LeadID + ")"; }
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; } }
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; } }