Ejemplo n.º 1
0
        public void DeleteContact()
        {
            List <Contact> contactList = _contactRepo.ReadAllContacts();

            //Console.Write("Enter last name of contact you want to remove > ");
            // string toRemove = Console.ReadLine();
            //int i = 0;
            //int s = 1;
            //foreach (var name in contactList)
            //{

            //    if (name.LastName.ToLower() == toRemove.ToLower())
            //    { Console.WriteLine($"ID : {name.Id} \t{name.LastName}, {name.FirstName} \n"); s++; }
            //    i++;
            //}
            Console.Write("Enter ID of person to delete > ");
            //ushort selected = Convert.ToUInt16(Console.ReadLine());
            string verifyInput = (Console.ReadLine());

            if (ushort.TryParse(verifyInput, out ushort selected))
            {
                var itemToRemove = _contactRepo.GetContactById(selected);
                if (itemToRemove == null)
                {
                    Console.WriteLine("ERROR: Check the ID number and try again.\n\n"); MenuOps.Menu();
                }

                Console.WriteLine($"\nSelected contact {itemToRemove.LastName}, {itemToRemove.FirstName}\n");
            }
            else
            {
                Console.WriteLine("ERROR: Check the ID number and try again.\n\n"); MenuOps.Menu();
            }

            Console.Write("Is this the contact you wish to remove? > ");
            string response = Console.ReadLine();

            if (response == "y")
            {
                _contactRepo.DeleteContact(selected); Console.WriteLine("\nContact Removed");
            }
            else
            {
                Console.WriteLine("Invalid Response. Return to the menu");
            }

            Console.WriteLine();
        }
Ejemplo n.º 2
0
        public void UpdateContact()
        {
            Contact newContact = new Contact();

            Console.Write("Enter contact ID number : >");

            string verifyInput = (Console.ReadLine());

            if (ushort.TryParse(verifyInput, out ushort getId))
            {
                var itemToUpdate = _contactRepo.GetContactById(getId);
                if (itemToUpdate == null)
                {
                    Console.WriteLine("ERROR: Check the ID number and try again.\n\n"); MenuOps.Menu();
                }

                Console.WriteLine($"\nSelected contact {itemToUpdate.LastName}, {itemToUpdate.FirstName}\n");
            }
            else
            {
                Console.WriteLine("ERROR: Check the ID number and try again.\n\n"); MenuOps.Menu();
            }



            var contactToUpdate = _contactRepo.GetContactById(getId);

            Console.WriteLine($"\nUpdating {contactToUpdate.FirstName} {contactToUpdate.LastName}\n");

            Console.Write("Enter first name > ");
            newContact.FirstName = Console.ReadLine();
            Console.Write("Enter last name > ");
            newContact.LastName = Console.ReadLine();
            Console.Write("Select contact type: \n\t 1. Customer \n\t 2. Potential Customer \n\nSelection > ");
            DateProcessing(newContact);

            _contactRepo.UpdateContact(getId, newContact);
        }
Ejemplo n.º 3
0
 public void Run()
 {
     SeedThis();
     MenuOps.Menu();
 }