Beispiel #1
0
        private void BtnDeleteFormContact_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> contact = this.GenerateContact();

            ContactWorker.RemoveContact(contact);

            this.HideForm();
            this.ShowList();
        }
Beispiel #2
0
        private void GridViewSort(object sender, RoutedEventArgs e)
        {
            var header = e.OriginalSource as GridViewColumnHeader;

            this.Contacts_List.Items.Clear();

            // Populate list
            foreach (Contact contact in ContactWorker.Sort(header.Content.ToString()))
            {
                this.Contacts_List.Items.Add(contact);
            }
        }
Beispiel #3
0
        private void Search_TextChanged(object sender, TextChangedEventArgs e)
        {
            this.Contacts_List.Items.Clear();

            Dictionary <int, string> search = new Dictionary <int, string>
            {
                { 0, this.search_firstname.Text },
                { 1, this.search_lastname.Text },
                { 2, this.search_email.Text },
                { 3, this.search_phone.Text }
            };

            foreach (Contact contact in ContactWorker.Search(search, this.currentUser))
            {
                this.Contacts_List.Items.Add(contact);
            }
        }
Beispiel #4
0
        private void ShowList()
        {
            this.Contacts_List.Visibility         = Visibility.Visible;
            this.BtnDisplayFormContact.Visibility = Visibility.Visible;
            this.Search_Bar.Visibility            = Visibility.Visible;

            this.search_firstname.Clear();
            this.search_lastname.Clear();
            this.search_email.Clear();
            this.search_phone.Clear();

            this.Contacts_List.Items.Clear();

            // Populate list
            foreach (Contact contact in ContactWorker.GetAllForUser(this.currentUser))
            {
                this.Contacts_List.Items.Add(contact);
            }
        }
Beispiel #5
0
        private void BtnContactValidate_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> contact = this.GenerateContact();

            List <string> errors = ContactWorker.ValidateContact(contact);

            this.FormContactErrorStack.Children.Clear();

            if (errors.Count > 0)
            {
                this.FormContactErrorStack.Visibility = Visibility.Visible;
                foreach (string error in errors)
                {
                    TextBlock text = new TextBlock();
                    text.Text          = error;
                    text.TextAlignment = TextAlignment.Center;
                    text.Foreground    = Brushes.Red;
                    text.FontWeight    = FontWeights.Bold;
                    text.FontSize      = 20;
                    this.FormContactErrorStack.Children.Add(text);
                }
            }
            else
            {
                if (this.input_id.Text == "")
                {
                    ContactWorker.AddContact(contact, this.currentUser);
                }
                else
                {
                    ContactWorker.UpdateContact(contact);
                }

                this.HideForm();
                this.ShowList();
            }
        }
Beispiel #6
0
 public ContactController(DataFactory dataFactory)
 {
     _contactWorker = (ContactWorker)dataFactory.GetDataFactory <Contact>();
 }