コード例 #1
0
 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;
 }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: jaimerosales/DreamSeat
 private void theContactsListBox_SelectedContactChanged(object aSender, Contact aContact)
 {
     theContactDetails.CurrentContact = aContact;
 }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: jaimerosales/DreamSeat
 private void theChangesListBox_ContactChanged(object aSender, Contact aContact)
 {
     if ((theContactDetails.CurrentContact != null) && (theContactDetails.CurrentContact.Id == aContact.Id))
         theContactDetails.CurrentContact = aContact;
     theContactsListBox.UpdateContact(aContact);
 }
コード例 #6
0
        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
                }
            }
        }
コード例 #7
0
 public Contact Post(Contact contact, HttpResponseMessage response)
 {
     this.repository.Post(contact);
     response.StatusCode = HttpStatusCode.Created;
     return contact;
 }
コード例 #8
0
 private void OnContactChanged(Contact aContact)
 {
     if (ContactChanged != null)
         ContactChanged(this, aContact);
 }
コード例 #9
0
 public void Post(Contact contact)
 {
     contact.ContactId = nextContactID++;
     contacts.Add(contact);
 }
コード例 #10
0
 private void SelectContact(Contact first)
 {
     ScrollViewer scrollViewer = GetScrollViewer(listView) as ScrollViewer;
     listView.SelectedItem = first;
     scrollViewer.ScrollToBottom();
     listView.ScrollIntoView(first);
     listView.Focus();
 }
コード例 #11
0
 public Contact Put(string id, Contact contact, HttpResponseMessage response)
 {
     this.Get(id, response);
     this.repository.Update(contact);
     return contact;
 }