public void Update(Contact updatedContact) { var contact = this.Get(updatedContact.ContactId); contact.Name = updatedContact.Name; contact.Address = updatedContact.Address; contact.City = updatedContact.City; contact.State = updatedContact.State; contact.Zip = updatedContact.Zip; contact.Email = updatedContact.Email; contact.Twitter = updatedContact.Twitter; }
public void UpdateContact(Contact aContact) { for (int i = 0; i < Items.Count; i++) { if (((Contact)Items[i]).Id == aContact.Id) { Items.Remove(Items[i]); break; } } Items.Add(aContact); Sort(); }
public ContactListPage() { Title = "My Contacts"; NavigationPage.SetHasNavigationBar(this, true); listView = new ListView { RowHeight = 40, ItemTemplate = new DataTemplate(typeof(ContactCell)) }; listView.ItemSelected += (sender, e) => { var contact = (Contact)e.SelectedItem; var contactPage = new ContactPage(); contactPage.BindingContext = contact; Navigation.PushAsync(contactPage); }; var layout = new StackLayout(); layout.Children.Add(listView); layout.VerticalOptions = LayoutOptions.FillAndExpand; Content = layout; ToolbarItem tbi = null; if (Device.OS == TargetPlatform.iOS) { tbi = new ToolbarItem("+", null, () => { var contact = new Contact(); var contactPage = new ContactPage(); contactPage.BindingContext = contact; Navigation.PushAsync(contactPage); }, 0, 0); } if (Device.OS == TargetPlatform.Android) { tbi = new ToolbarItem("+", "plus", () => { var contact = new Contact(); var contactPage = new ContactPage(); contactPage.BindingContext = contact; Navigation.PushAsync(contactPage); }, 0, 0); } ToolbarItems.Add(tbi); }
private void theContactsListBox_SelectedContactChanged(object aSender, Contact aContact) { theContactDetails.CurrentContact = aContact; }
private void theChangesListBox_ContactChanged(object aSender, Contact aContact) { if ((theContactDetails.CurrentContact != null) && (theContactDetails.CurrentContact.Id == aContact.Id)) theContactDetails.CurrentContact = aContact; theContactsListBox.UpdateContact(aContact); }
private void theSaveButton_Click(object sender, EventArgs e) { bool isNew = theContact == null; if (isNew) { theContact = new Contact(); } theContact.FirstName = theFirstNameTextBox.Text; theContact.LastName = theLastNameTextBox.Text; theContact.EmailAddresses.Clear(); foreach (var email in theEmailsTextBox.Text.Trim().Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)) { theContact.EmailAddresses.Add(email.Trim()); } if (isNew) { theContact = Database.CreateDocument<Contact>(theContact, new Result<Contact>()).Wait(); if (imageAvatar.Image != null && openFileDialog.FileName.Trim() != String.Empty) { Database.AddAttachment(theContact, openFileDialog.FileName, new Result<JObject>()).Wait(); } } else { try { theContact = Database.UpdateDocument<Contact>(theContact, new Result<Contact>()).Wait(); if (imageAvatar.Image != null && openFileDialog.FileName.Trim() != String.Empty) { Database.AddAttachment(theContact, openFileDialog.FileName, new Result<JObject>()).Wait(); } } catch (Exception exc) { //TODO } } }
public Contact Post(Contact contact, HttpResponseMessage response) { this.repository.Post(contact); response.StatusCode = HttpStatusCode.Created; return contact; }
private void OnContactChanged(Contact aContact) { if (ContactChanged != null) ContactChanged(this, aContact); }
public void Post(Contact contact) { contact.ContactId = nextContactID++; contacts.Add(contact); }
private void SelectContact(Contact first) { ScrollViewer scrollViewer = GetScrollViewer(listView) as ScrollViewer; listView.SelectedItem = first; scrollViewer.ScrollToBottom(); listView.ScrollIntoView(first); listView.Focus(); }
public Contact Put(string id, Contact contact, HttpResponseMessage response) { this.Get(id, response); this.repository.Update(contact); return contact; }