コード例 #1
0
        private void Delete()
        {
            Console.Clear();

            Console.WriteLine("Delete phone!");
            Console.WriteLine();

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

            Console.WriteLine("PHONE ID:");
            foreach (Contact con in contacts)
            {
                Console.WriteLine("           " + con.ID + "     " + con.ToString());
            }
            Console.Write("Chooce ID: ");
            int id = int.Parse(Console.ReadLine());

            Contact contact = contactRepo.GetContactById(id);

            if (contact == null)
            {
                Console.WriteLine("Contact not found!");
            }
            else
            {
                contactRepo.DeletePhone(contact);
                Console.WriteLine("Contact deleted successfully.");
            }
            Console.ReadKey(true);
        }