Exemple #1
0
        private void AddNewContact(object obj)
        {
            bool contactExist = false;

            if (ContactList.Any())
            {
                if (ContactList[SelectedContactIndexList].FirstName == ContactFirstName && ContactList[SelectedContactIndexList].LastName == ContactLastName)
                {
                    contactExist = true;
                }
            }

            if (!contactExist)
            {
                Contact contact = new Contact();
                if (ContactTelephoneNumber != 0)
                {
                    Telephone newTelephone = new Telephone
                    {
                        Number   = ContactTelephoneNumber,
                        Operator = ContactPhoneOperator,
                        Type     = ContactPhoneType
                    };
                    contact.Telephones = new List <Telephone>();
                    contact.Telephones.Add(newTelephone);

                    ContactTelephpones.Add(newTelephone);
                }

                if (!string.IsNullOrEmpty(ContactAddressStreet))
                {
                    Address address = new Address
                    {
                        City     = ContactAddressCity,
                        PostCode = ContactPostCode,
                        Street   = ContactAddressStreet
                    };
                    contact.Address = new Address();
                    contact.Address = address;
                }

                contact.FirstName = ContactFirstName;
                contact.LastName  = ContactLastName;

                _contactRepository.AddContact(contact);
                ContactList.Add(contact);

                GetContactDetails();
                GetTelephoneDetails();
                GetNumberofObjectsInDatabase();
            }
        }
Exemple #2
0
        private void AddNewPhone(object obj)
        {
            Telephone newTelephone = new Telephone
            {
                Number   = ContactTelephoneNumber,
                Operator = ContactPhoneOperator,
                Type     = ContactPhoneType
            };

            _contactRepository.AddTelephone(newTelephone, ContactList[SelectedContactIndexList]);
            ContactTelephpones.Add(newTelephone);
            GetNumberofObjectsInDatabase();
        }