public CreateCustomerDialogViewModel(Contact item) { InnerItem = item; InnerItem.PropertyChanged += InnerItem_PropertyChanged; EmailForUserInput=new Email(); PhoneForUserInput = new Phone(); }
private void ShowAddPhone() { if (!IsPhoneInEditMode) { IsPhoneInEditMode = true; NewPhone = new Phone {Type = "Primary"}; } else { if (SaveNewPhoneCommand.CanExecute()) { SaveNewPhoneCommand.Execute(); IsPhoneInEditMode = false; } } }
private void EditPhone(Phone item) { if (AddAddressPhoneEmailInteractioNRequest != null) { var phoneToEdit = item.DeepClone(_entityFactory as IKnownSerializationTypes); var itemVm = _phoneVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("item", phoneToEdit)); var confirmation = new ConditionalConfirmation { Title = "Enter phone details", Content = itemVm }; AddAddressPhoneEmailInteractioNRequest.Raise(confirmation, (x) => { if (x.Confirmed) { var phoneToUpdate = (x.Content as IPhoneNumberDialogViewModel) .InnerItem; var itemFromInnerItem = ContactPhones.SingleOrDefault( p => p.PhoneId == phoneToUpdate.PhoneId); if (itemFromInnerItem != null) { itemFromInnerItem.InjectFrom(phoneToUpdate); _parentViewModel.IsModified = true; } } }); } }
private void RemovePhone(Phone item) { if (ContactPhones != null) { ContactPhones.Remove(item); AddPhoneCommand.RaiseCanExecuteChanged(); } }
public PhoneNumberDialogViewModel(Phone item) { InnerItem = item; InnerItem.PropertyChanged+=InnerItem_PropertyChanged; }
public void AddEditAndRemovePhoneFromContactTest() { var client = GetRepository(); Contact contactFromDb = client.Members.OfType<Contact>(). Expand(c => c.Phones).FirstOrDefault(); client.Attach(contactFromDb); Assert.IsNotNull(contactFromDb); //create new phone Phone phoneToAdd = new Phone(); phoneToAdd.Number = "228810"; contactFromDb.Phones.Add(phoneToAdd); client.UnitOfWork.Commit(); client = GetRepository(); Contact contactForCheck = client.Members.OfType<Contact>(). Expand(c => c.Phones).FirstOrDefault(); client.Attach(contactForCheck); Assert.IsNotNull(contactForCheck); //get phone for update var phoneForCheck = contactForCheck.Phones.Where(p => p.PhoneId == phoneToAdd.PhoneId).SingleOrDefault(); Assert.IsNotNull(phoneForCheck); phoneForCheck.Number = "666"; client.UnitOfWork.Commit(); client = GetRepository(); contactForCheck = client.Members.OfType<Contact>(). Expand(c => c.Phones).FirstOrDefault(); Assert.IsNotNull(contactFromDb); phoneForCheck = contactForCheck.Phones.Where(p => p.PhoneId == phoneToAdd.PhoneId).SingleOrDefault(); Assert.IsNotNull(phoneForCheck); Assert.IsTrue(phoneForCheck.Number == "666"); }
public void Can_edit_Phone_in_Contact() { var client = GetRepository(); var contactWithNewPhone = new Contact(); contactWithNewPhone.FullName = "test"; //create new phone var phoneToAdd = new Phone(); phoneToAdd.Number = "228810"; contactWithNewPhone.Phones.Add(phoneToAdd); client.Add(contactWithNewPhone); client.UnitOfWork.Commit(); client = GetRepository(); var contactForCheck = client.Members.OfType<Contact>(). Expand(c => c.Phones).FirstOrDefault(); client.Attach(contactForCheck); Assert.NotNull(contactForCheck); //get phone for update var phoneForCheck = contactForCheck.Phones.Where(p => p.PhoneId == phoneToAdd.PhoneId).SingleOrDefault(); Assert.NotNull(phoneForCheck); phoneForCheck.Number = "666"; client.UnitOfWork.Commit(); client = GetRepository(); contactForCheck = client.Members.OfType<Contact>(). Expand(c => c.Phones).FirstOrDefault(); Assert.NotNull(contactForCheck); phoneForCheck = contactForCheck.Phones.Where(p => p.PhoneId == phoneToAdd.PhoneId).SingleOrDefault(); Assert.NotNull(phoneForCheck); Assert.True(phoneForCheck.Number == "666"); }