Ejemplo n.º 1
0
        static void DisplayData(char option)
        {
            var viewModel = new ContactsViewModel();

            switch (option)
            {
            case 'a':
                Console.Clear();
                Loader(5, 20);
                Console.Clear();
                var contacts = viewModel.DisplayAllContacts();

                foreach (var contact in contacts)
                {
                    Console.WriteLine($"{contact.Id}\t: {contact.FirstName} {contact.LastName} :{contact.TelephoneNumber}");
                }
                break;

            case 'b':
            {
                Console.Clear();
                Loader(5, 20);
                Console.Clear();
                Console.WriteLine("Enter user firstName");
                var username = Console.ReadLine();
                var results  = viewModel.DisplaySearchResults(username);
                foreach (var contact in results)
                {
                    Console.WriteLine($"{contact.Id}   : {contact.FirstName} {contact.LastName} :{contact.TelephoneNumber}");
                }
                break;
            }

            case 'c':
                Console.Clear();
                Loader(5, 20);
                Console.Clear();
                Console.WriteLine("Enter Contact ID");
                var usernameId = Convert.ToInt32(Console.ReadLine());
                viewModel.DisplayContactById(usernameId);
                break;

            case 'd':
                Environment.Exit(0);
                break;

            default:
                Console.WriteLine("Invalid Input");

                break;
            }
        }