Пример #1
0
        public void editContact()
        {
            if (contactList.Count == 0)
            {
                Console.WriteLine("\nNo contacts in the Address Book to edit now ...");
            }
            else
            {
                Console.WriteLine("\nProvide first_name of contact to be edited : ");
                string  first_name = Console.ReadLine();
                Contact contact    = null;
                try
                {
                    contact = contactDetailsMap[first_name];
                }
                catch (KeyNotFoundException exception)
                {
                    Console.WriteLine(exception.Message);
                }
                finally
                {
                    userInput(contact);
                    Console.WriteLine("\nDetails edited successfully...");

                    //FileInputOutput file = new FileInputOutput();
                    //file.WriteContactsIntoFile(contactList);
                    FileInputOutput.JsonSerializeDeserialize(contactList);
                }
            }
        }
Пример #2
0
 public void deleteContact()
 {
     if (contactList.Count == 0)
     {
         Console.WriteLine("\nNo contacts in the Address Book to delete now...");
     }
     else
     {
         Console.Write("\nProvide first_name of contact to be deleted : ");
         string first_name = Console.ReadLine();
         try
         {
             contactList.Remove(contactDetailsMap[first_name]);
             contactDetailsMap.Remove(first_name);
             Console.WriteLine("\nContact " + first_name + " deleted successfully...");
             //FileInputOutput file = new FileInputOutput();
             //file.WriteContactsIntoFile(contactList);
             FileInputOutput.JsonSerializeDeserialize(contactList);
         }
         catch (KeyNotFoundException exception)
         {
             Console.WriteLine(exception.Message);
         }
     }
 }
Пример #3
0
        //To create a contact in address book
        public void createContact()
        {
            Contact contact = new Contact();

            userInput(contact);
            contactList.Add(contact);
            cityMapWithPerson.Add(contact, contact.City);
            stateMapWithPerson.Add(contact, contact.State);
            contactDetailsMap.Add(contact.FirstName, contact);
            Console.WriteLine("\nNew contact created...");

            //FileInputOutput file = new FileInputOutput();
            //file.WriteContactsIntoFile(contactList);
            FileInputOutput.JsonSerializeDeserialize(contactList);
        }