Esempio n. 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);
        }
Esempio n. 2
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);
            }
        }