Beispiel #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                using (var db = new ContactDatabase())
                {
                    var log = new ContactLog()
                    {
                        Name     = txtName.Text,
                        Email    = txtEmail.Text,
                        Subject  = txtSubject.Text,
                        Message  = txtMessage.Text,
                        DateSent = DateTime.Now
                    };

                    db.ContactLogs.Add(log);
                    db.SaveChanges();

                    pnlFormFields.Visible     = false;
                    pnlSuccessMessage.Visible = true;
                }
            }
            else
            {
            }
        }
Beispiel #2
0
        public void GivenAddressBook_DoPost_ShouldReturnAddedAddressDetails()
        {
            // arrange
            RestRequest request    = new RestRequest("/address", Method.POST);
            JObject     objectBody = new JObject
            {
                { "FirstName", "Kylie" },
                { "LastName", "McMiller" },
                { "Address", "Sidewalk 3/41" },
                { "City", "Lockenwille" },
                { "State", "WoodLer" },
                { "Zip", "521432" },
                { "PhoneNumber", "7548965265" },
                { "Email", "*****@*****.**" }
            };

            request.AddParameter("application/json", objectBody, ParameterType.RequestBody);

            // act
            IRestResponse response = client.Execute(request);

            // assert
            Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
            ContactDatabase dataResponse = JsonConvert.DeserializeObject <ContactDatabase>(response.Content);

            Assert.AreEqual("Kylie", dataResponse.firstname);
            Assert.AreEqual("McMiller", dataResponse.lastname);
            Assert.AreEqual("Sidewalk 3/41", dataResponse.address);
            Assert.AreEqual("Lockenwille", dataResponse.city);
            Assert.AreEqual("WoodLer", dataResponse.state);
            Assert.AreEqual("521432", dataResponse.zip);
            Assert.AreEqual("7548965265", dataResponse.phone);
            Assert.AreEqual("*****@*****.**", dataResponse.email);
        }
Beispiel #3
0
        public void GivenAddressBook_OnPut_ShouldReturnUpdatedAddressDetails()
        {
            // arrange
            RestRequest request    = new RestRequest("/address/5", Method.PUT);
            JObject     objectBody = new JObject();

            objectBody.Add("FirstName", "lyka");
            objectBody.Add("LastName", "krab");
            objectBody.Add("Address", "UnderWater");
            objectBody.Add("City", "OceanStreet");
            objectBody.Add("State", "Middlleton");
            objectBody.Add("Zip", "912405");
            objectBody.Add("PhoneNumber", "8565555489");
            objectBody.Add("Email", "*****@*****.**");

            request.AddParameter("application/json", objectBody, ParameterType.RequestBody);

            // act
            IRestResponse response = client.Execute(request);

            // assert
            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
            ContactDatabase dataResponse = JsonConvert.DeserializeObject <ContactDatabase>(response.Content);

            Assert.AreEqual("lyka", dataResponse.firstname);
            Assert.AreEqual("*****@*****.**", dataResponse.email);
        }
Beispiel #4
0
        async void SendMessage()
        {
            string          defaultMsg = "Help me";
            string          emergency  = "Personal";
            MessageDatabase mdb        = new MessageDatabase(dbPath);
            var             msg        = await mdb.GetMessageAsync(emergency);

            if (msg.MessageTemplate == null)
            {
                msg.MessageTemplate = defaultMsg;
            }
            ContactDatabase cdb  = new ContactDatabase(dbPath);
            var             list = await cdb.GetContactsAsync(emergency);

            if (list.Count() > 0)
            {
                foreach (Contact contact in list)
                {
                    DependencyService.Get <ISendSMS>().Send(contact.ContactNumber, msg.MessageTemplate);
                }
            }
            else
            {
                DependencyService.Get <IToast>().Toasts("hasData", "failed");
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     using (var db = new ContactDatabase())
     {
         //Response.Write(db.ContactLogs.Count().ToString());
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     using (var db = new ContactDatabase())
     {
         MessageRepeater.DataSource = db.ContactLogs.ToArray();
         MessageRepeater.DataBind();
     }
 }
Beispiel #7
0
        public void OnSwiped(object s, EventArgs e)
        {
            this.IsVisible = false;
            ContactDatabase db = new ContactDatabase(dbPath);

            DependencyService.Get <IToast>().Toasts("deleteContact", db.DeleteContact(Convert.ToInt32(this.contactId.Text)));
            MessagingCenter.Send <App>((App)Application.Current, "OnContactDeleted");
        }
Beispiel #8
0
        public ActionResult LogList()
        {
            var messages = new List <ContactMessage>();

            using (var db = new ContactDatabase())
            {
                messages.AddRange(db.ContactMessages.ToArray());
            }

            return(View(messages));
        }
        // POST api/Contact
        public void Post(string firstName, string lastName, string email, int phnNum)
        {
            ContactDatabase contactDatabase = new ContactDatabase();
            Contact         contactList     = contactDatabase.SaveContact(firstName, lastName, email, phnNum);

            var newContact = new ContactDetails {
                FirstName   = contactList.FirstName,
                LastName    = contactList.LastName,
                Email       = contactList.Email,
                PhoneNumber = contactList.PhoneNumber
            };
        }
Beispiel #10
0
        public async void NewContact(string emergency)
        {
            noContact.IsVisible = false;
            contacts.IsVisible  = true;
            ContactDatabase db      = new ContactDatabase(dbPath);
            var             contact = await db.GetNewContactAsync(emergency);

            NewContact newContact = new NewContact(emergency);

            newContact.contactId.Text     = contact.ContactId.ToString();
            newContact.contactName.Text   = contact.ContactName;
            newContact.contactNumber.Text = contact.ContactNumber;
            contactList.Children.Add(newContact);
        }
Beispiel #11
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            Args = e.Args;

            CreateJumpList();

            // Make the main process appear connected to the update process
            // in the taskbar.
            try { SetCurrentProcessExplicitAppUserModelID(GlobalAssemblyInfo.AssemblyName); }
            catch { }

            AppointmentDatabase.Load();
            AppointmentDatabase.OnSaveCompletedEvent += AppointmentDatabase_OnSaveCompletedEvent;
            ContactDatabase.Load();
            ContactDatabase.OnSaveCompletedEvent += ContactDatabase_OnSaveCompletedEvent;
            TaskDatabase.Load();
            TaskDatabase.OnSaveCompletedEvent += TaskDatabase_OnSaveCompletedEvent;
            NoteDatabase.Load();
            NoteDatabase.OnSaveCompletedEvent += NoteDatabase_OnSaveCompletedEvent;
            SyncDatabase.Load();
            SyncDatabase.OnSaveCompletedEvent += SyncDatabase_OnSaveCompletedEvent;
            QuoteDatabase.Load();
            QuoteDatabase.OnSaveCompletedEvent += QuoteDatabase_OnSaveCompletedEvent;

            ThemeHelpers.UpdateTheme(true);

            MainWindow mainWindow = new MainWindow();

            mainWindow.ContentRendered += mainWindow_ContentRendered;
            mainWindow.Show();

            SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
            SystemEvents.TimeChanged           += SystemEvents_TimeChanged;

            if (BackstageEvents.StaticUpdater == null)
            {
                BackstageEvents.StaticUpdater = new BackstageEvents();
            }

            BackstageEvents.StaticUpdater.OnForceUpdateEvent     += StaticUpdater_OnForceUpdateEvent;
            BackstageEvents.StaticUpdater.OnThemeChangedEvent    += StaticUpdater_OnThemeChangedEvent;
            BackstageEvents.StaticUpdater.OnExportEvent          += StaticUpdater_OnExportEvent;
            BackstageEvents.StaticUpdater.OnHelpEvent            += StaticUpdater_OnHelpEvent;
            BackstageEvents.StaticUpdater.OnDocumentRequestEvent += StaticUpdater_OnDocumentRequestEvent;
            BackstageEvents.StaticUpdater.OnPrintStartedEvent    += StaticUpdater_OnPrintStartedEvent;
            BackstageEvents.StaticUpdater.OnImportEvent          += StaticUpdater_OnImportEvent;
            BackstageEvents.StaticUpdater.OnQuotesChangedEvent   += StaticUpdater_OnQuotesChangedEvent;
        }
        public void Delete(int id)
        {
            ContactDatabase contactDatabase = new ContactDatabase();
            bool            IsDeleted       = contactDatabase.DeleteContact(id);

            if (IsDeleted)
            {
                Console.WriteLine("Contact Deleted");
            }
            else
            {
                Console.WriteLine("Contact cant be deleted");
            }
        }
        public async void ShowData(string emergency, int id)
        {
            ContactDatabase db      = new ContactDatabase(dbPath);
            var             Contact = await db.GetContactAsync(emergency, id);

            EmergencyName = Contact.EmergencyName;
            ContactName   = Contact.ContactName;
            ContactNumber = Contact.ContactNumber;
            //var _db = App.EmergencyDatabase.GetEmergency(emergency);
            //EmergencyImage = emergency.ToLower() + ".png";
            //EmergencyName = _db.EmergencyName;
            //ContactName = _db.ContactName;
            //ContactNumber = _db.ContactNumber;
            //MessageTemplate = _db.MessageTemplate;
        }
Beispiel #14
0
        public static async Task <List <Contact> > ImportContact(Window owner, StatusStrip statusStrip, string rootFolder = null)
        {
            statusStrip.UpdateMainStatus("IMPORTING...");

            FileDialog open = new FileDialog(owner,
                                             rootFolder == null ? Environment.GetFolderPath(Environment.SpecialFolder.Personal) : rootFolder,
                                             FileDialogType.Open, ListViewMode.Detail);

            open.Title  = "Import Contact";
            open.Filter = "VCard Contact Files (*.vcf)|.vcf";
            //open.IconSize = IconSize.Small;
            open.FilterIndex = 0;
            //open.RootFolder = rootFolder == null ? Environment.GetFolderPath(Environment.SpecialFolder.Personal) : rootFolder;
            openDialog = open;

            List <Contact> list = null;

            if (open.ShowDialog() == true)
            {
                try
                {
                    string file = open.SelectedFile;

                    await Task.Factory.StartNew(() =>
                    {
                        list = Contact.ParseVCard(file);

                        foreach (Contact each in list)
                        {
                            ContactDatabase.Add(each);
                        }
                    });

                    statusStrip.UpdateMainStatus("READY");
                }
                catch (Exception exc)
                {
                    list = null;
                    statusStrip.UpdateMainStatus("ERROR: " + exc.Message.ToUpper());
                }
            }
            else
            {
                statusStrip.UpdateMainStatus("READY");
            }

            return(list);
        }
        public ContactDetails GetContactById(int id)
        {
            ContactDatabase contactDatabase = new ContactDatabase();
            var             contact         = contactDatabase.GetContactById(id);

            var contactInfo = new ContactDetails
            {
                Id          = contact.Id,
                FirstName   = contact.FirstName,
                LastName    = contact.LastName,
                Email       = contact.Email,
                PhoneNumber = contact.PhoneNumber
            };

            return(contactInfo);
        }
Beispiel #16
0
        private void RecoverContact(Contact contact)
        {
            FlowDocument document = contact.NotesDocument;

            contact.SaveChangesToDisk = true;
            contact.NotesDocument     = document;

            ContactDatabase.UpdateContact(contact);
            new RecoveryDatabase(RecoveryVersion.LastRun).RecoveryContact = null;

            if (peopleView != null)
            {
                peopleView.UpdateContact(contact);
            }

            PeoplePeekContent.UpdateAll(contact);
        }
Beispiel #17
0
        public async void ShowContact(string emergency)
        {
            contactList.Children.Clear();
            noContact.IsVisible = false;
            contacts.IsVisible  = true;
            ContactDatabase db   = new ContactDatabase(dbPath);
            var             list = await db.GetContactsAsync(emergency);

            foreach (Contact contact in list)
            {
                NewContact newContact = new NewContact(emergency);
                newContact.contactId.Text     = contact.ContactId.ToString();
                newContact.contactName.Text   = contact.ContactName;
                newContact.contactNumber.Text = contact.ContactNumber;
                contactList.Children.Add(newContact);
            }
        }
Beispiel #18
0
        public ActionResult Index(ContactMessage post)
        {
            if (ModelState.IsValid)
            {
                using (var db = new ContactDatabase())
                {
                    post.DateSent = DateTime.Now;

                    db.ContactMessages.Add(post);

                    db.SaveChanges();
                }

                TempData["ContactMessage"] = post;
                return(RedirectToAction("SuccessfulMessage"));
            }

            return(View(post));
        }
Beispiel #19
0
        public ActionResult Log(int?id = null)
        {
            if (!id.HasValue)
            {
                return(LogList());
            }

            using (var db = new ContactDatabase())
            {
                var message = db.ContactMessages.SingleOrDefault(m => m.ID == id);

                if (message != null)
                {
                    return(View("LogSingle", message));
                }
            }

            return(new HttpNotFoundResult());
        }
        public void GivenDataFromDatabase_RetrievedData()
        {
            ContactDatabase expected = new ContactDatabase()
            {
                firstname = "Shakira",
                lastname  = "Shamina",
                city      = "Mumbai",
                phone     = "7452166",
                B_Name    = "Book1",
                B_Type    = "Family"
            };
            var actual = AddressBookRepo.GetAllContacts();

            Assert.AreEqual(expected.firstname, actual.firstname);
            Assert.AreEqual(expected.lastname, actual.lastname);
            Assert.AreEqual(expected.city, actual.city);
            Assert.AreEqual(expected.phone, actual.phone);
            Assert.AreEqual(expected.B_Name, actual.B_Name);
            Assert.AreEqual(expected.B_Type, actual.B_Type);
        }
        public async void OnAdd(object function)
        {
            ContactDatabase db = new ContactDatabase(dbPath);

            if (CheckFields())
            {
                switch (function)
                {
                case "Add":
                    var Contact = new Contact()
                    {
                        EmergencyName = emergencyName,
                        ContactName   = contactName,
                        ContactNumber = contactNumber
                    };
                    //   DependencyService.Get<IToast>().Toasts("custom",emergency);
                    DependencyService.Get <IToast>().Toasts("addContact", db.AddContact(Contact));
                    ContactName   = "";
                    ContactNumber = "";
                    MessagingCenter.Send <App>((App)Application.Current, "OnContactAdded");
                    break;

                case "Update":
                    var UpdateContact = await db.GetContactAsync(emergencyName, contactId);

                    UpdateContact.ContactName   = contactName;
                    UpdateContact.ContactNumber = contactNumber;
                    DependencyService.Get <IToast>().Toasts("updateContact", db.UpdateContact(UpdateContact));
                    MessagingCenter.Send <App>((App)Application.Current, "OnContactUpdated");
                    await PopupNavigation.Instance.PopAsync(true);

                    break;
                }
            }
            else
            {
                DependencyService.Get <IToast>().Toasts("addContact", "failed");
            }
        }
Beispiel #22
0
        public async void CountContact(string function, string emergency)
        {
            int             contactCount = 0;
            ContactDatabase db           = new ContactDatabase(dbPath);

            contactCount = await db.CountContact(emergency);

            if (contactCount > 0)
            {
                if (function == "Init")
                {
                    ShowContact(emergency);
                }
            }

            else
            {
                noContact.IsVisible = true;
                contacts.IsVisible  = false;
            }
            //
        }
        // GET api/values/5
        public List <ContactDetails> GetAllContacts()
        {
            ContactDatabase contactDatabase = new ContactDatabase();
            var             contactList     = contactDatabase.GetAllContacts();
            var             allcontacts     = (from c in contactList
                                               select new ContactDetails
            {
                Id = c.Id,
                FirstName = c.FirstName,
                LastName = c.LastName,
                Email = c.Email,
                PhoneNumber = c.PhoneNumber,
                IsActive = c.Status
            }).ToList();

            ///To Save a Contact
            ///Post("xyz","lmn","*****@*****.**",12345);

            ///Delete a Contact
            ///Delete(3); --Id to deleted

            return(allcontacts);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var db = new ContactDatabase())
            {
                // CONTACT/LOG/1/
                var id      = RouteData.Values["contactLogId"];
                var intId   = Convert.ToInt32(id);
                var message = db.ContactLogs.SingleOrDefault(l => l.ID == intId);

                if (message != null)
                {
                    Name.Text     = message.Name;
                    Email.Text    = message.Email;
                    DateSent.Text = message.DateSent.ToString();
                    Subject.Text  = message.Subject;
                    Message.Text  = message.Message;
                }
                else
                {
                    error.Text = "Cannt find a message with that id";
                }
            }
        }
Beispiel #25
0
        protected override void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);

            //
            // Save databases
            //
            AppointmentDatabase.OnSaveCompletedEvent -= AppointmentDatabase_OnSaveCompletedEvent;
            AppointmentDatabase.Save();
            ContactDatabase.OnSaveCompletedEvent -= AppointmentDatabase_OnSaveCompletedEvent;
            ContactDatabase.Save();
            TaskDatabase.OnSaveCompletedEvent -= TaskDatabase_OnSaveCompletedEvent;
            TaskDatabase.Save();
            NoteDatabase.OnSaveCompletedEvent -= NoteDatabase_OnSaveCompletedEvent;
            NoteDatabase.Save();
            SyncDatabase.OnSaveCompletedEvent -= SyncDatabase_OnSaveCompletedEvent;
            SyncDatabase.Save();

            //
            // Unregister system hooks
            //
            SystemEvents.UserPreferenceChanged -= SystemEvents_UserPreferenceChanged;
            SystemEvents.TimeChanged           -= SystemEvents_TimeChanged;

            //
            // Delete autorecover information
            //
            new RecoveryDatabase(RecoveryVersion.Current).Delete();
            new RecoveryDatabase(RecoveryVersion.LastRun).Delete();

            //
            // Install any updates which may have been downloaded.
            //
            string localPath = (new FileInfo(Process.GetCurrentProcess().MainModule.FileName)).DirectoryName;

            Process.Start(localPath + "\\UpdateManager.exe", "/update " + Process.GetCurrentProcess().Id.ToString());
        }
        public override void Load()
        {
            string[] favorites = Settings.PeopleFavorites;

            contactsListBox.Items.Clear();

            if (favorites == null || favorites.Length == 0)
            {
                message.Visibility = Visibility.Visible;
                return;
            }

            contactsListBox.Visibility = Visibility.Visible;
            message.Visibility         = Visibility.Hidden;

            foreach (string each in favorites)
            {
                Contact c = ContactDatabase.GetContact(each);
                if (c != null)
                {
                    PeopleView.SmartInsert(contactsListBox, c);
                }
            }

            //
            // BUG FIX: Since a contact is not placed in database until it is saved,
            // a contact marked as "Favorite" would be inaccessible.
            //
            if (!contactsListBox.HasItems)
            {
                contactsListBox.Visibility = Visibility.Hidden;
                message.Visibility         = Visibility.Visible;
                FrictionScrollViewerControl scrollViewer = (FrictionScrollViewerControl)contactsListBox.Template.FindName("_tv_scrollviewer_", contactsListBox);
                scrollViewer.LayoutVerticalScrollBar();
                scrollViewer.LayoutHorizontalScrollBar();
            }
        }
Beispiel #27
0
        // --

        public MainViewModel(ContactDatabase contacts)
        {
            OnInfectionStatusChange(this, contacts.CurrentInfectionStatus);
            contacts.CurrentInfectionStatusChange += OnInfectionStatusChange;
        }
 public DetailsViewModel(ContactDatabase contacts)
 {
     OnMatchesChange(this, contacts.Matches);
     contacts.MatchesChange += OnMatchesChange;
 }
			// <param name="peerUri">the peer uri of the conversation participant</param>
			// <param name="usingDisplayName">the display name the participant is claiming to be</param>
			// <param name="usingAvatarUrl">the avatar the participant is claiming to be</param>
			// <param name="outContacts">optional returned list of existing contacts matching to this peer URI and the value is set to null if no existing contacts were found</param>
			// <param name="outPreviousName">optionally returned if contacts were not found the this value will be set with the last known display name (if a record was found)</param>
			// <param name="outPreviousAvatarUrl">optionally returned if contacts were not found the this value will be set with the last known avatar url (if a record was found)</param>
			public int GetOrCreateParticipantIdForConversation (
				string peerUri,
				string usingDisplayName,
				string usingAvatarUrl,
				ContactDatabase contactDb,
				OptionalOut< IList<Contact> > outContacts = null,
				OptionalOut<string> outPreviousName = null,
				OptionalOut<string> outPreviousAvatarUrl = null
			)
			{
				Contract.Requires (!String.IsNullOrEmpty(peerUri));
				Contract.Requires (contactDb != null);

				int resultParticipantId = 0;
				IList<Contact> resultContacts = null;

				string previousName = usingDisplayName;
				string previousAvatar = usingAvatarUrl;

				try {
					lock (this) {

						#region this needs to change
						#warning needs to do proper split using op stack

						char[] delimiterChars = {'/'};
						string[] split = peerUri.Split (delimiterChars, StringSplitOptions.RemoveEmptyEntries);

						Contract.Assert (split.Length > 2);

						string contactId = split [2];

						Contract.Assert (!String.IsNullOrEmpty (contactId));
						#endregion

						// find any contacts which are associated to this peer URI contact id
						resultContacts = contactDb.GetByPeerUriContactId (contactId);

						IList<ConversationPartipantRecord> existingRecordsForContactId = GetParticipantRecordByPeerUriContactId (contactId);

						if (!Helper.IsNullOrEmpty(existingRecordsForContactId)) {

							ConversationPartipantRecord record = existingRecordsForContactId.First ();

							// if we found a contact id that means the user is the same user as there cannot be any two users sharing the same contact id (ever)
							resultParticipantId = record.ParticipantId;

							previousName = record.LastKnownDisplayName;
							previousAvatar = record.LastKnownAvatarUrl;

							Logger.Debug("found existing participant record for contact id, participant id={0}, peer uri={1}", resultParticipantId, peerUri);
						}

						List<Contact> contactsMissingRecords = new List<Contact> ();

						// search all contacts to see if any have existing records (and which records are missing)
						foreach (Contact contact in resultContacts) {
							bool foundRecordForThisIdentity = false;
							IList<ConversationPartipantRecord> records = GetParticipantRecordByIdentityUri(contact.IdentityUri);

							foreach (ConversationPartipantRecord record in records) {
								if ((!String.IsNullOrEmpty(record.StableId)) &&
									(!String.IsNullOrEmpty(contact.StableId))) {
									if (record.StableId != contact.StableId) {
										Logger.Trace ("previous participant record was found for identity uri but stable id doesn't match thus skipping, identity uri={0}, contact stable id={1}, record stable id={2}", contact.IdentityUri, contact.StableId, record.StableId);
										continue;
									}

									foundRecordForThisIdentity = foundRecordForThisIdentity || String.Equals(contact.PeerUri, peerUri);	// make sure it's the same peer URI (they can be different)

									bool updated = false;

									// if the record display name / avatar have changed, update the record
									if (!String.Equals (contact.DisplayName, record.LastKnownDisplayName)) {
										updated = true;
										record.LastKnownDisplayName = contact.DisplayName;
									}
									if (!String.Equals (contact.AvatarUrl, record.LastKnownAvatarUrl)) {
										updated = true;
										record.LastKnownAvatarUrl = contact.AvatarUrl;
									}

									if (updated) {
										record.LastUpdated = DateTime.UtcNow;
										Update (record);
									}

									if (0 == resultParticipantId) {
										resultParticipantId = record.ParticipantId;
										Logger.Debug("found participant record for contact based on identity uri, participant id={0}, peer uri={1}, identity uri={2}", resultParticipantId, peerUri, contact.IdentityUri);
										continue;
									}

									Logger.Debug("found participant record for contact based on identity uri higher priority used, participant id={0}, peer uri={1}, identity uri={2}", resultParticipantId, peerUri, contact.IdentityUri);
								}
							}

							if (!foundRecordForThisIdentity) {
								contactsMissingRecords.Add (contact);
							}
						}

						bool createdNewParticipantId = false;

						// check to see if a participant id was chosen (needs one to be able to add any missing records)
						if (0 == resultParticipantId) {
							createdNewParticipantId = true;

							++lastParticipantId;
							resultParticipantId = lastParticipantId;
						}

						// scan over missing records to add them now
						if (!Helper.IsNullOrEmpty(resultContacts)) {
							foreach (Contact contact in contactsMissingRecords) {
								ConversationPartipantRecord record = new ConversationPartipantRecord ();
								record.IdentityUri = contact.IdentityUri;
								record.PeerUri = peerUri;
								record.PeerUriContactId = contactId;
								record.StableId = contact.StableId;
								record.ParticipantId = resultParticipantId;
								record.LastKnownDisplayName = contact.DisplayName;
								record.LastKnownAvatarUrl = contact.AvatarUrl;

								Insert (record);

								Logger.Trace ("added missing participant record for idenity, participant id={0}, identity={1}, stable id={2}, peer uri={3}", record.ParticipantId, record.IdentityUri, record.StableId, record.PeerUri);
							}
						} else {
							if (createdNewParticipantId) {
								ConversationPartipantRecord record = new ConversationPartipantRecord ();
								record.IdentityUri = "";
								record.PeerUri = peerUri;
								record.PeerUriContactId = contactId;
								record.StableId = "";
								record.ParticipantId = resultParticipantId;
								record.LastKnownDisplayName = usingDisplayName;
								record.LastKnownAvatarUrl = usingAvatarUrl;

								Insert (record);

								Logger.Trace ("added missing participant record for peer uri, participant id={0}, peer uri={1}", record.ParticipantId, record.PeerUri);
							}
						}
					}
				} finally {
					if (null != outContacts) {
						if (!Helper.IsNullOrEmpty (resultContacts)) {
							outContacts.Result = resultContacts;
						} else {
							outContacts.Result = new List<Contact> ();
						}
					}

					if (Helper.IsNullOrEmpty (resultContacts)) {
						if (null != outPreviousName) {
							outPreviousName.Result = previousName;
						}
						if (null != outPreviousAvatarUrl) {
							outPreviousAvatarUrl.Result = previousAvatar;
						}
					}
				}

				return resultParticipantId;
			}
        public ContactDefinition(ContactDatabase contactDatabase)
        {
            _contactDatabase = contactDatabase;

            ConfigureOptions = options => { options.Search.Allow = true; };
        }
        private void search(object _query)
        {
            string[] query =
                Daytimer.Search.Search.StripWhitespace
                (
                    Daytimer.Search.Search.RemovePunctuation
                    (
                        (
                            (string)_query
                        ).ToLower()
                    )
                )
                .Trim()
                .Split(' ');

            List <Contact> results = new List <Contact>();

            if (query.Length > 0 && !string.IsNullOrEmpty(query[0]))
            {
                foreach (Contact each in ContactDatabase.GetContacts())
                {
                    if (contactMatchesQuery(query, each))
                    {
                        results.Add(each);
                    }
                }
            }

            if (_cancel)
            {
                return;
            }

            if (results.Count > 0)
            {
                Dispatcher.Invoke(() =>
                {
                    if (_cancel)
                    {
                        return;
                    }

                    statusBar.Text             = "RESULTS (" + results.Count.ToString() + ")";
                    message.Text               = "";
                    contactsListBox.Visibility = Visibility.Visible;

                    contactsListBox.Items.Clear();

                    foreach (Contact each in results)
                    {
                        contactsListBox.Items.Add(each);
                    }
                });
            }
            else
            {
                Dispatcher.Invoke(() =>
                {
                    if (_cancel)
                    {
                        return;
                    }

                    statusBar.Text = "NO RESULTS";
                    message.Text   = "We couldn't find the person you were looking for. You can try using the more powerful main search (Ctrl+F).";
                    contactsListBox.Items.Clear();
                    contactsListBox.Visibility = Visibility.Hidden;
                });
            }
        }