private void UpdateContact(string distinguishedName) { MailContactObject updateContact = new MailContactObject(); updateContact.DisplayName = txtDisplayName.Text; updateContact.Hidden = cbHidden.Checked; // Create new contact ExchangeContactViewModel viewModel = new ExchangeContactViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; viewModel.UpdateContact(distinguishedName, updateContact); GetContacts(); }
private void CreateContact() { MailContactObject newContact = new MailContactObject(); newContact.DisplayName = txtDisplayName.Text; newContact.Email = txtEmail.Text; newContact.Hidden = cbHidden.Checked; // Create new contact ExchangeContactViewModel viewModel = new ExchangeContactViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; viewModel.NewContact(WebSessionHandler.SelectedCompanyCode, newContact); GetContacts(); }
private void GetContact(string distinguishedName) { ExchangeContactViewModel viewModel = new ExchangeContactViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; MailContactObject contact = viewModel.GetContact(distinguishedName); hfContactDistinguishedName.Value = distinguishedName; txtDisplayName.Text = contact.DisplayName; txtEmail.Text = contact.Email; cbHidden.Checked = contact.Hidden; txtEmail.ReadOnly = true; panelContactList.Visible = false; panelEditContact.Visible = true; }
public void NewContact(string companyCode, MailContactObject mailContact) { ExchangePowershell powershell = null; CPDatabase database = null; try { // Get company distinguished name database = new CPDatabase(); var dn = (from c in database.Companies where !c.IsReseller where c.CompanyCode == companyCode select c.DistinguishedName).First(); powershell = new ExchangePowershell(StaticSettings.ExchangeURI, StaticSettings.Username, StaticSettings.DecryptedPassword, StaticSettings.ExchangeUseKerberos, StaticSettings.PrimaryDC); string distinguishedName = powershell.NewContact(mailContact.DisplayName, mailContact.Email, mailContact.Hidden, companyCode, "OU=Exchange," + dn); // Add contact to database Contact newContact = new Contact(); newContact.DisplayName = mailContact.DisplayName; newContact.CompanyCode = companyCode; newContact.DistinguishedName = distinguishedName; newContact.Email = mailContact.Email; newContact.Hidden = mailContact.Hidden; database.Contacts.Add(newContact); database.SaveChanges(); } catch (Exception ex) { ThrowEvent(Base.Enumerations.AlertID.FAILED, ex.Message); } finally { if (database != null) { database.Dispose(); } if (powershell != null) { powershell.Dispose(); } } }
public void UpdateContact(string distinguishedName, MailContactObject mailContact) { ExchangePowershell powershell = null; CPDatabase database = null; try { // Get company distinguished name database = new CPDatabase(); var contact = (from c in database.Contacts where c.DistinguishedName == distinguishedName select c).First(); powershell = new ExchangePowershell(StaticSettings.ExchangeURI, StaticSettings.Username, StaticSettings.DecryptedPassword, StaticSettings.ExchangeUseKerberos, StaticSettings.PrimaryDC); string returnedDN = powershell.UpdateContact(distinguishedName, mailContact.DisplayName, mailContact.Hidden); contact.DistinguishedName = returnedDN; database.SaveChanges(); } catch (Exception ex) { ThrowEvent(Base.Enumerations.AlertID.FAILED, ex.Message); } finally { if (database != null) { database.Dispose(); } if (powershell != null) { powershell.Dispose(); } } }