public void createAddressBook() { AddressBookMain addressBookMain = new AddressBookMain(); while (true) { Console.Write("Enter user name of Address Book : "); string userInput = Console.ReadLine(); Regex regex = new Regex(@"^[A-Za-z]+$"); if (regex.IsMatch(userInput)) { if (addressBookDetailsMap.ContainsKey(userInput)) { Console.WriteLine(userInput + " address book already exists on the system..."); break; } addressBookMain.addressBookUserName = userInput; addressBookList.Add(addressBookMain); addressBookDetailsMap.Add(addressBookMain.addressBookUserName, addressBookMain); Console.WriteLine("\nNew Address Book created..."); break; } else { Console.WriteLine("Invalid Input... Please enter correctly... ->Only alphabets allowed"); } } }
public void accessAddressBook(AddressBookMain addressBookUser) { int choice = 0; while (choice != 6) { Console.Write("You're currently in AddressBookUser : "******"\nPress 1. To add Contact \n" + " 2. To view Contacts\n" + " 3. To edit a Contact\n" + " 4. To delete a Contact\n" + " 5. To get Number of contacts from city/state\n" + " 6. Go to address books\n" + "Your Choice .: "); try { choice = Convert.ToInt32(Console.ReadLine()); } catch (FormatException exception) { Console.WriteLine(exception.Message); } finally { switch (choice) { case 1: addressBookUser.createContact(); break; case 2: addressBookUser.viewContactNames(); break; case 3: addressBookUser.editContact(); break; case 4: addressBookUser.deleteContact(); break; case 5: addressBookUser.countOfCities(); break; case 6: Console.WriteLine("\nThank You for using user AddressBook of : " + addressBookUser.addressBookUserName + " ..."); break; default: Console.WriteLine("\nPlease enter valid choice..."); break; } } } }
static void Main(string[] args) { AddressBookMain newProgram = new AddressBookMain(); Console.WriteLine("Welcome to the Address Book Program!"); bool exist = true; while (exist) { string BookName; ArrayList ContactList = new ArrayList(); Dictionary <string, ArrayList> Book = new Dictionary <string, ArrayList>(); Console.WriteLine("Enter new address book name : "); BookName = Console.ReadLine(); Console.WriteLine("Select the option. \n1. Add new contact. \n2. Edit existing contact. \n3. Delete existing contact \n4. Exit."); int option = int.Parse(Console.ReadLine()); switch (option) { case 1: { newProgram.book.AddPerson(); Book.Add(BookName, ContactList); Console.WriteLine("Contact added!"); Console.WriteLine("New count of contacts in address book : " + Book.Count); break; } case 2: { Console.WriteLine("Enter the first name of that person: "); newProgram.book.EditPersonDetails(); break; } case 3: { Console.WriteLine("Enter the first name of that person: "); newProgram.book.DeletePersonDetails(); Console.WriteLine("New count of contacts in address book : " + Book.Count); break; } case 4: { exist = false; break; } } } }
public void addNewAddressBook() { Console.WriteLine("Enter the name of address book:"); string addressBookName = Console.ReadLine(); AddressBookMain addressBook = new AddressBookMain(addressBookName); addressBookListDictionary.Add(addressBookName, addressBook); Console.WriteLine("\nAddress Book " + addressBookName + " added successfully"); Console.WriteLine("Updated Address Book List:"); foreach (var kvp in addressBookListDictionary) { Console.WriteLine("Key: {0}, Value: {1}", kvp.Key, kvp.Value); //Log record with every new address book addition to the system nLog.LogInfo("addNewAddressBook()) passed: to add new address book with name : " + kvp.Key); //Console.WriteLine(addressBookListDictionary.ElementAt[0].viewContact()); } //Console.WriteLine(addressBookListDictionary["addressBookName"].Convert.toBool(viewContact("Ram", "Kumar"))); //Debug message to show method got debugged successfully nLog.LogDebug("Debug Successful : addNewAddressBook()"); }