Example #1
0
        /// <summary>
        /// Adds a new contact or updates an existing contact. Called by ContactPage.
        /// </summary>
        /// <param name="contact">New Contact</param>
        /// <returns>Result of operation</returns>
        public MLResult SaveContact(MLContactsContact contact)
        {
            Log("Saving...");

            ulong    requestHandle = 0;
            MLResult result;

            if (!string.IsNullOrEmpty(contact.ID))
            {
                Debug.LogFormat("Updating existing contact with id = {0}", contact.ID);
                result = MLContacts.UpdateContact(contact, out requestHandle);
            }
            else
            {
                Debug.LogFormat("Saving new contact with name = {0}", contact.Name);
                result = MLContacts.AddContact(contact, out requestHandle);
            }

            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: ContactsExample failed to save contact. Reason: {0}", result);
                Log(string.Format("<color=red>Failed to save contact. {0}</color>", result));
            }

            return(result);
        }
        /// <summary>
        /// Build the UI from the given contact. If the contact is new,
        /// immediately go to edit mode. Otherwise, go to view mode.
        /// Called by ContactsExample.
        /// </summary>
        /// <param name="contact">Contact to load</param>
        public void Populate(MLContactsContact contact)
        {
            _contact = contact;

            if (string.IsNullOrEmpty(contact.ID))
            {
                _contact.Name = "<i>Name</i>";
                HandleBeginEdit();
            }
            else
            {
                IsEditing = false;
                UpdateHeaderButtons();
                Refresh();
            }
        }
Example #3
0
        /// <summary>
        /// Rebuilds the displayed list. Called by ContactsExample.
        /// </summary>
        /// <param name="contacts">List of contacts to display</param>
        public void PopulateList(List <MLContactsContact> contacts)
        {
            DestroyListItems();

            for (int i = 0; i < contacts.Count; ++i)
            {
                MLContactsContact contact       = contacts[i];
                GameObject        contactItemGO = Instantiate(_contactItem.gameObject, transform);
                contactItemGO.transform.localPosition = new Vector3(-0.25f, 0.04f - (0.03f * i), 0);

                ContactItem contactItem = contactItemGO.GetComponent <ContactItem>();
                contactItem.ListPage    = this;
                contactItem.ID          = contact.ID;
                contactItem.ContactName = contact.Name;

                _contactGOList.Add(contactItemGO);
            }
        }
Example #4
0
 /// <summary>
 /// Validates a contact.
 /// </summary>
 /// <param name="contact">Contact to be validated</param>
 /// <returns>Result of Validation</returns>
 public MLResult ValidateContact(MLContactsContact contact)
 {
     return(MLContacts.ValidateContact(contact));
 }