Exemplo n.º 1
0
        private void Edit()
        {
            Console.Clear();

            Console.WriteLine("Edit Phone!");
            Console.WriteLine();

            ContactsRepository contactRepo     = new ContactsRepository();
            List <Contact>     contacts        = contactRepo.GetContacts(AuthenticationService.LoggedUser.ID);
            Contact            originalContact = new Contact();

            Console.WriteLine("PHONE ID:");
            foreach (Contact con in contacts)
            {
                originalContact.ID     = con.ID;
                originalContact.UserId = con.UserId;
                Console.WriteLine("           " + con.ID + "     " + con.ToString());
            }

            Console.Write("Chooce ID: ");
            int id = int.Parse(Console.ReadLine());

            Contact contact = contactRepo.GetContactById(id);

            if (contact.ID == originalContact.ID && contact.UserId == originalContact.UserId)
            {
                Console.WriteLine("Enter your new phone!");
                Console.Write("Here: ");
                contact.Phone = Console.ReadLine();
                contactRepo.EditPhone(contact);
            }
            else
            {
                Console.WriteLine("No match!");
                Console.ReadKey(true);
            }
        }