public CreateCustomerDialogViewModel(Contact item) { InnerItem = item; InnerItem.PropertyChanged += InnerItem_PropertyChanged; EmailForUserInput=new Email(); PhoneForUserInput = new Phone(); }
private void ShowAddEmail() { if (IsEmailInEditMode) { if (SaveNewEmailCommand.CanExecute()) { SaveNewEmailCommand.Execute(); IsEmailInEditMode = false; } } else { NewEmail = new Email {Type = "Primary"}; IsEmailInEditMode = true; } }
private void EditEmail(Email item) { if (AddAddressPhoneEmailInteractioNRequest != null) { var emailToEdit = item.DeepClone(_entityFactory as IKnownSerializationTypes); var itemVm = _emailVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("item", emailToEdit)); var confirmation = new ConditionalConfirmation { Title = "Enter email details", Content = itemVm }; AddAddressPhoneEmailInteractioNRequest.Raise(confirmation, (x) => { if (x.Confirmed) { var itemTUpdate = (x.Content as IEmailDialogViewModel) .InnerItem; var itemFromInnerItem = ContactEmails.SingleOrDefault( e => e.EmailId == itemTUpdate.EmailId); if (itemFromInnerItem != null) { itemFromInnerItem.InjectFrom(itemTUpdate); _parentViewModel.IsModified = true; } } }); } }
private void MakePrimaryEmail(Email item) { if (ContactEmails != null) { foreach (var emailItem in ContactEmails) { emailItem.Type = null; } item.Type = EmailType.Primary.ToString(); _parentViewModel.IsModified = true; } }
private void RemoveEmail(Email item) { if (ContactEmails != null) { ContactEmails.Remove(item); } }
public void AddEmailToExitingCase() { var client = GetRepository(); var caseFromDb = client.Cases.Expand(c => c.CommunicationItems).Expand(c => c.Labels).Expand(c => c.Notes).Expand(c => c.Contact) .FirstOrDefault(); Assert.IsNotNull(caseFromDb); Assert.IsNotNull(caseFromDb.Contact); caseFromDb.Contact = client.Members.Where(m => m.MemberId == caseFromDb.Contact.MemberId) .OfType<Contact>().Expand(c => c.Addresses).Expand(c => c.Emails).Expand(c => c.Labels) .Expand(c => c.Notes).Expand(c => c.Phones).SingleOrDefault(); client.Attach(caseFromDb); Email emailToAdd = new Email(); emailToAdd.Address = "*****@*****.**"; emailToAdd.Type = "Primary"; caseFromDb.Contact.Emails.Add(emailToAdd); client.UnitOfWork.Commit(); client = GetRepository(); caseFromDb = client.Cases.Expand(c => c.CommunicationItems).Expand(c => c.Labels).Expand(c => c.Notes).Expand(c => c.Contact) .FirstOrDefault(); Assert.IsNotNull(caseFromDb); Assert.IsNotNull(caseFromDb.Contact); caseFromDb.Contact = client.Members.Where(m => m.MemberId == caseFromDb.Contact.MemberId) .OfType<Contact>().Expand(c => c.Addresses).Expand(c => c.Emails).Expand(c => c.Labels) .Expand(c => c.Notes).Expand(c => c.Phones).SingleOrDefault(); var emailFromDb = caseFromDb.Contact.Emails.Where(e => e.EmailId == emailToAdd.EmailId).SingleOrDefault(); Assert.IsNotNull(emailFromDb); }
public void Can_create_Email_in_Contact() { var client = GetRepository(); var contactWithNewEmail = new Contact(); contactWithNewEmail.FullName = "test"; var emailToAdd = new Email(); emailToAdd.Address = "*****@*****.**"; emailToAdd.Type = "Primary"; contactWithNewEmail.Emails.Add(emailToAdd); client.Add(contactWithNewEmail); client.UnitOfWork.Commit(); client = GetRepository(); var contactFromDb = client.Members.OfType<Contact>() .Where(c => c.MemberId == contactWithNewEmail.MemberId) .Expand(c => c.Emails) .SingleOrDefault(); Assert.NotNull(contactFromDb); Assert.True(contactFromDb.Emails.Count == 1); }
public ActionResult Edit(ChangeAccountInfoModel model) { if (ModelState.IsValid) { // ChangePassword will throw an exception rather // than return false in certain failure scenarios. bool changePasswordSucceeded; var needToChangePassword = !String.IsNullOrEmpty(model.OldPassword) && !String.IsNullOrEmpty(model.NewPassword); try { changePasswordSucceeded = !needToChangePassword || _webSecurity.ChangePassword(UserHelper.CustomerSession.Username, model.OldPassword, model.NewPassword); } catch (Exception) { changePasswordSucceeded = false; } var u = _userClient.GetCurrentCustomer(false) ?? _userClient.NewContact(); u.FullName = model.FullName; var primaryEmail = u.Emails.FirstOrDefault(e => e.Type == EmailType.Primary.ToString()); if (primaryEmail != null) { primaryEmail.Address = model.Email; } else { var newEmail = new Email { Address = model.Email, MemberId = u.MemberId, Type = EmailType.Primary.ToString() }; u.Emails.Add(newEmail); } _userClient.SaveCustomerChanges(u.MemberId); if (needToChangePassword) { if (changePasswordSucceeded) { TempData[GetMessageTempKey(MessageType.Success)] = new[] { "Password was succesfully changed!".Localize() }; return RedirectToAction("Index"); } ModelState.AddModelError("", @"The current password is incorrect or the new password is invalid."); } else { TempData[GetMessageTempKey(MessageType.Success)] = new[] { "Your account was succesfully updated!".Localize() }; return RedirectToAction("Index"); } } // If we got this far, something failed, redisplay form return View("Edit", model); }
public EmailDialogViewModel(Email item) { InnerItem = item; InnerItem.PropertyChanged += InnerItem_PropertyChanged; }