Ejemplo n.º 1
0
        private void Btn_AddContact_Click(object sender, RoutedEventArgs e)
        {
            ContactInfo w = new ContactInfo();

            w.Fill(new Contact(), ContactsCollection.ContactTypes);
            w.ShowDialog();

            //Getting Contact From
            var tContact = w.GetContact();

            tContact.ID = CounterID++;
            //Добавляем контакт если он ен пустой
            if (!tContact.IsEmpty())
            {
                Contacts.Add(tContact);
            }

            //Sorting Contacts
            Contacts.Sort(SortType);
            //Contacts.SortByFullName();
            lb_ContactBox.Items.Refresh();

            //SaveJson
            Contacts.SaveToJson();
        }
Ejemplo n.º 2
0
 private void LoadContacts(ICollection <ContactUi> contacts)
 {
     ContactsCollection.Clear();
     foreach (var contactUi in contacts)
     {
         ContactsCollection.Add(contactUi);
     }
 }
        public void GivenANewContactsCollection_WhenAddingAContact_ThenANewContactShouldBeFoundAtPosition0()
        {
            ContactsCollection cc = new ContactsCollection();

            cc.Add("name", "phoneNumber");
            Assert.AreEqual("name", cc[0].Name);
            Assert.AreEqual("phoneNumber", cc[0].PhoneNumber);

            ContactsCollection people = cc.Where(checkIfPhoneNumberStrtsWith06);

            ContactsCollection people2 = cc.Where(contact => contact.PhoneNumber.StartsWith("06"));
        }
Ejemplo n.º 4
0
        public void AddContactButton_RaiseContactAddedEvent(object sender, ContactAddedEventArgs e)
        {
            var contact = IMService.GetUser(e.Username);

            if (contact != null)
            {
                IMService.AddContact(LoggedInUser, contact);
                ContactsCollection.Add(contact);
                ContactsDetails.Add(new ContactDetails {
                    Username = contact.Username, FirstName = contact.FirstName, LastName = contact.LastName
                });
            }
        }
Ejemplo n.º 5
0
        public static ContactsCollection GetAllItem()
        {
            ContactsCollection collection = new ContactsCollection();

            using (var reader = SqlHelper.ExecuteReader("Contacts_GetAll", null))
            {
                while (reader.Read())
                {
                    Contacts obj = new Contacts();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Ejemplo n.º 6
0
        public static ContactsCollection GetbyUser(string CreatedUser)
        {
            ContactsCollection collection = new ContactsCollection();
            Contacts           obj;

            using (var reader = SqlHelper.ExecuteReader("Contacts_GetAll_byUser", new SqlParameter("@CreatedUser", CreatedUser)))
            {
                while (reader.Read())
                {
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Ejemplo n.º 7
0
 private void InitContactsCollection(List <User> contactList)
 {
     if (ContactsCollection == null)
     {
         ContactsCollection = new ObservableCollection <User>();
     }
     else
     {
         foreach (var contact in ContactsCollection.ToList())
         {
             ContactsCollection.Remove(contact);
         }
     }
     foreach (var contact in contactList)
     {
         ContactsCollection.Add(contact);
     }
 }
Ejemplo n.º 8
0
 private void CheckForNewMessagesAndContacts()
 {
     if (LoggedInUser != null && SelectedContact != null)
     {
         var messagesList = IMService.GetAllMessagesBetweenContacts(LoggedInUser, GetSelectedUser());
         foreach (var message in messagesList)
         {
             if (MessagesCollection.Count(c => c.Id == message.Id) == 0)
             {
                 MessagesCollection.Add(message);
             }
         }
         var contactsList = IMService.GetContacts(LoggedInUser);
         foreach (var contact in contactsList)
         {
             if (ContactsCollection.Count(c => c.Username == contact.Username) == 0)
             {
                 ContactsCollection.Add(contact);
                 AddToContactsDetails(contact);
             }
         }
     }
 }