コード例 #1
0
        public void View()
        {
            while (true)
            {
                Console.Clear();
                Console.WriteLine("#####################################");
                Console.WriteLine("##### Y O U R    C O N T A C T S ####");
                Console.WriteLine("#####################################");
                Console.WriteLine("############# [A]dd #################");
                Console.WriteLine("############# [L]ist ################");
                Console.WriteLine("############# [E]dit ################");
                Console.WriteLine("############# [D]elite ##############");
                Console.WriteLine("############# E[x]it ################");
                Console.WriteLine("########## YOUR CHOICE: ");
                string choice = Console.ReadLine();
                Console.Clear();
                ContactRepo repository = new ContactRepo("contacts.txt");
                var         contacts   = repository.List(AuthenticationService.LogUser.Id);
                switch (choice.ToUpper())
                {
                case "A":
                    AddContact(repository, AuthenticationService.LogUser.Id);
                    break;

                case "L":
                    RenderContacts(contacts);
                    Console.ReadKey(true);
                    break;

                case "E":
                    RenderContacts(contacts);
                    Console.WriteLine("#####################################");
                    Console.Write("##### EDIT CONTACT BY ID : ");
                    EditContact(repository, contacts, int.Parse(Console.ReadLine()));
                    Console.Clear();
                    Console.WriteLine("#########################");
                    Console.WriteLine("####### D O N E ! #######");
                    Console.WriteLine("#########################");
                    Thread.Sleep(1000);
                    break;

                case "D":
                    RenderContacts(contacts);
                    Console.WriteLine("#####################################");
                    Console.Write("##### DELETE CONTACT BY ID : ");
                    repository.Delete(int.Parse(Console.ReadLine()));
                    Console.Clear();
                    Console.WriteLine("#########################");
                    Console.WriteLine("####### D O N E ! #######");
                    Console.WriteLine("#########################");
                    Thread.Sleep(1000);
                    break;

                case "X":
                    Environment.Exit(0);;
                    break;

                default:
                    Console.Clear();
                    Console.WriteLine("#####################################");
                    Console.WriteLine("########### Wrong Command! ##########");
                    Console.WriteLine("#####################################");
                    Thread.Sleep(2000);
                    break;
                }
            }
        }