public static LeadContact Get(int contactID) { LeadContact contact = (from x in DbContextHelper.DbContext.LeadContact.Include("LeadContactType") where x.isActive == true && x.ID == contactID select x).FirstOrDefault(); return(contact); }
public void AssociateLeadToContact(int leadId, int ContactId, int UserId) { LeadContact leadContact = new LeadContact(); leadContact.LeadId = leadId; leadContact.ContactId = ContactId; leadContact.CreatedBy = UserId; leadContact.CreatedDate = DateTime.UtcNow; leadContactRepository.Insert(leadContact); }
public static void Save(LeadContact contact) { if (contact.ID == 0) { contact.DateCreated = DateTime.Now; DbContextHelper.DbContext.Add(contact); } DbContextHelper.DbContext.SaveChanges(); }
protected void btnSaveContact_Click(object sender, EventArgs e) { Page.Validate("Contact"); if (!Page.IsValid) { return; } int leadID = Convert.ToInt32(Session["LeadIds"]); int policyTypeID = Convert.ToInt32(ViewState["policyTypeID"]); int contactID = 0; int contactTypeID = Convert.ToInt32(ddlContactType.SelectedValue); LeadContact contact = null; contactID = Convert.ToInt32(ViewState["ContactID"]); if (contactID == 0) { contact = new LeadContact(); } else { contact = LeadContactManager.Get(contactID); } if (contact != null) { contact.ID = contactID; contact.LeadID = leadID; contact.ContactName = txtContactName.Text; contact.isActive = true; contact.Mobile = txtContactPhone.Text; contact.Email = txtContactEmail.Text; contact.PolicyTypeID = policyTypeID; if (ddlContactType.SelectedIndex > 0) { contact.ContactTypeID = contactTypeID; } else { contact.ContactTypeID = null; } LeadContactManager.Save(contact); showContactGrid(); // refresh screen bindData(leadID, policyTypeID); } }
public void AssociateLeadToContact(List <LeadContactModel> leadContactModelList, int createdBy) { List <LeadContact> LeadContactList = new List <LeadContact>(); foreach (LeadContactModel leadContactModel in leadContactModelList) { LeadContact acccontact = new LeadContact(); acccontact.LeadId = leadContactModel.LeadId; acccontact.ContactId = leadContactModel.ContactId; acccontact.CreatedBy = createdBy; acccontact.CreatedDate = DateTime.UtcNow; LeadContactList.Add(acccontact); } leadContactRepository.InsertAll(LeadContactList); }
protected void gvContacts_RowCommand(object sender, GridViewCommandEventArgs e) { LeadContact contact = null; int contactID = Convert.ToInt32(e.CommandArgument); int leadID = Convert.ToInt32(Session["LeadIds"]); int policyTypeID = Convert.ToInt32(ViewState["policyTypeID"]); if (e.CommandName == "DoEdit") { contact = LeadContactManager.Get(contactID); if (contact != null) { showContactPanel(); txtContactName.Text = contact.ContactName; txtContactEmail.Text = contact.Email; txtContactPhone.Text = contact.Mobile; try { ddlContactType.SelectedValue = contact.ContactTypeID.ToString(); } catch { } ViewState["ContactID"] = contact.ID; } } if (e.CommandName == "DoRemove") { contactID = Convert.ToInt32(e.CommandArgument); try { contact = LeadContactManager.Get(contactID); contact.isActive = false; LeadContactManager.Save(contact); bindData(leadID, policyTypeID); } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblContactMessage.Text = "Record Not Deleted."; lblContactMessage.Visible = true; } } }
protected void btnSaveContact_Click(object sender, EventArgs e) { Page.Validate("Contact"); if (!Page.IsValid) return; int leadID = Convert.ToInt32(Session["LeadIds"]); int policyTypeID = Convert.ToInt32(ViewState["policyTypeID"]); int contactID = 0; int contactTypeID = Convert.ToInt32(ddlContactType.SelectedValue); LeadContact contact = null; contactID = Convert.ToInt32(ViewState["ContactID"]); if (contactID == 0) { contact = new LeadContact(); } else contact = LeadContactManager.Get(contactID); if (contact != null) { contact.ID = contactID; contact.LeadID = leadID; contact.ContactName = txtContactName.Text; contact.isActive = true; contact.Mobile = txtContactPhone.Text; contact.Email = txtContactEmail.Text; contact.PolicyTypeID = policyTypeID; if (ddlContactType.SelectedIndex > 0) contact.ContactTypeID = contactTypeID; else contact.ContactTypeID = null; LeadContactManager.Save(contact); showContactGrid(); // refresh screen bindData(leadID, policyTypeID); } }
protected void copyContacts(int sourceLeadID, int targetLeadID) { List<LeadContact> contacts = LeadContactManager.GetContactByLeadID(sourceLeadID); if (contacts != null && contacts.Count > 0) { foreach (LeadContact contact in contacts) { LeadContact newContact = new LeadContact(); newContact.ContactName = contact.ContactName; newContact.CityID = contact.CityID; newContact.CompanyAddress = contact.CompanyAddress; newContact.CompanyName = contact.ContactName; newContact.ContactTypeID = contact.ContactTypeID; newContact.DateCreated = contact.DateCreated; newContact.Email = contact.Email; newContact.InsuranceTypeID = contact.InsuranceTypeID; newContact.isActive = contact.isActive; newContact.LeadID = targetLeadID; newContact.Mobile = contact.Mobile; newContact.Phone = contact.Phone; newContact.PolicyTypeID = contact.PolicyTypeID; newContact.StateID = contact.StateID; newContact.ZipCode = contact.ZipCode; LeadContactManager.Save(newContact); } } }
public int AddContact(ContactModel contactModel) { Contact contact = new Contact(); AutoMapper.Mapper.Map(contactModel, contact); contact.CreatedDate = DateTime.UtcNow; contact.ModifiedBy = contactModel.ModifiedBy; contact.CreatedBy = contactModel.CreatedBy; contact.ModifiedDate = DateTime.UtcNow; contact.Address = null; contact.User = null; contact.Address = ValidateAddress(contact.Address, contactModel.AddressModel); if (contactModel.AccountId > 0) { AccountContact accountcontact = new AccountContact(); accountcontact.AccountId = contactModel.AccountId; accountcontact.CreatedBy = contactModel.CreatedBy; accountcontact.CreatedDate = DateTime.UtcNow; contact.AccountContacts.Add(accountcontact); } if (contactModel.LeadId > 0) { LeadContact leadcontact = new LeadContact(); leadcontact.LeadId = contactModel.LeadId.Value; leadcontact.CreatedBy = contactModel.CreatedBy; leadcontact.CreatedDate = DateTime.UtcNow; contact.LeadContacts.Add(leadcontact); } contactRepository.Insert(contact); List <int> lisTagIds = new List <int>(); if (!string.IsNullOrEmpty(contactModel.ContactTagIds)) { string[] arrTagIds = contactModel.ContactTagIds.Split(','); int tagId = 0; for (int i = 0; i < arrTagIds.Length; i++) { tagId = arrTagIds[i].Decrypt(); lisTagIds.Add(tagId); } } if (!string.IsNullOrEmpty(contactModel.NewTagNames)) { List <int> lisNewAddedTagIds = new List <int>(); lisNewAddedTagIds = AddTagsToSystem(contactModel.NewTagNames, contactModel.CompanyId, contactModel.CreatedBy); if (lisNewAddedTagIds.Count > 0) { lisTagIds = lisTagIds.Concat(lisNewAddedTagIds).ToList(); } } //Associate Tagids to contact if (lisTagIds.Count > 0) { ContactTag contactTag; for (int i = 0; i < lisTagIds.Count; i++) { contactTag = new ContactTag(); contactTag.ContactId = contact.ContactId; contactTag.TagId = lisTagIds[i]; contactTagRepository.Insert(contactTag); } } return(contact.ContactId); }