/// <summary> /// method for adding, editing, deleting the person details /// </summary> /// <param name="addressBook">The address book.</param> public static void FillAddressBook(AddressBook addressBook) { int choice; do { Console.WriteLine("\t\t\t__________________________________\n" + "\t\t\t| Menu |\n" + "\t\t\t| ------ |\n" + "\t\t\t| 1. Add Contact |\n" + "\t\t\t| 2. Edit Contact |\n" + "\t\t\t| 3. Delete Contact |\n" + "\t\t\t| 4. File I/P Operation |\n" + "\t\t\t| 5. File O/P Operation |\n" + "\t\t\t| 6. Sort By firstname |\n" + "\t\t\t| 7. Display all |\n" + "\t\t\t| 8. Sort by city or state or zip |\n" + "\t\t\t| 0.Exit |\n" + "\t\t\t|_________________________________|"); choice = (int)InputInteger(); switch (choice) { case 1: Contact contact = new Contact(); SetContactDetails(contact); addressBook.AddContact(contact); break; case 2: Console.WriteLine("Enter the Phone Number of Contact you wish to Edit"); long phoneNumber = (long)InputInteger(); //calls FindByPhoneNum to get index of input phoneNumber int index = addressBook.FindByPhoneNum(phoneNumber); if (index == -1) { Console.WriteLine("No Contact Exists With Following Phone Number"); continue; } else { Contact contact2 = new Contact(); //Calls SetContactDetails method to add person detals SetContactDetails(contact2); //Add contact to list addressBook.ContactList[index] = contact2; Console.WriteLine("Contact Updated Successfully"); } break; case 3: Console.WriteLine("Enter the First Name of Contact you wish to delete"); string firstName = InputString(); //FindByFirstName gets index of person based on first name int index1 = addressBook.FindByFirstName(firstName); if (index1 == -1) { Console.WriteLine("No Contact Exists with Following First Name"); continue; } else { //Calls delete contact and deletes details in particular index location addressBook.DeleteContact(index1); Console.WriteLine("Contact Deleted Successfully"); } break; case 4: FileIOOperations fileIOOperations = new FileIOOperations(); fileIOOperations.WriteToFile(AddressBookMap); break; case 5: FileIOOperations fileIOOperations1 = new FileIOOperations(); fileIOOperations1.ReadFromFile(); break; case 6: addressBook.SortByFirstName(); break; case 7: addressBook.Display(); break; case 8: Console.WriteLine("\t\t\t__________________________________\n" + "\t\t\t| ------ |\n" + "\t\t\t| 1. Sort by city |\n" + "\t\t\t| 2. Sort by zip |\n" + "\t\t\t| 3. Sort by state |\n" + "\t\t\t|_________________________________|"); int option = (int)InputInteger(); switch (option) { case 1: addressBook.SortByCity(); break; case 2: addressBook.SortByZip(); break; default: addressBook.SortByState(); break; } break; } } while (choice != 0); }