private static void AddEntry() { PhoneEntry entry = book.GetEntryByPage(book.AddEntry()); Console.Write("Page " + entry.PageNumber + "\nLast Name: "); entry.LastName = Console.ReadLine(); Console.Write("First Name: "); entry.FirstName = Console.ReadLine(); Console.Write("Patronymic: "); entry.Patronymic = Console.ReadLine(); bool success; do { Console.Write("Phone: "); success = entry.SetPhone(Console.ReadLine()); if (!success) { Console.WriteLine("Phone isn't correct. Try again."); } } while (!success); Console.Write("Country: "); entry.Country = Console.ReadLine(); do { Console.Write("Birthday: "); success = entry.SetBirthdayString(Console.ReadLine()); if (!success) { Console.WriteLine("Phone isn't correct. Try again."); } } while (!success); Console.Write("Company: "); entry.Company = Console.ReadLine(); Console.Write("Position: "); entry.Position = Console.ReadLine(); Console.Write("Notes: "); entry.Notes = Console.ReadLine(); Console.ReadKey(true); }
private static void ChangeEntry() { if (IsEmpty()) { return; } bool success = false; int page = 0; do { Console.Write("Number of the page: "); try { page = Convert.ToInt32(Console.ReadLine()); if (book.GetEntryByPage(page) == null) { success = false; Console.WriteLine("There is not such page in Phone Book. Try again."); } else { success = true; } } catch (Exception ex) { success = false; Console.WriteLine("Page number is not correct. Try again."); } } while (!success); PhoneEntry entry = book.GetEntryByPage(page); Console.Write("Last Name:\n" + entry.LastName); entry.LastName = EditString(entry.LastName); Console.Write("First Name:\n" + entry.FirstName); entry.FirstName = EditString(entry.FirstName); Console.Write("Patronymic:\n" + entry.Patronymic); entry.Patronymic = EditString(entry.Patronymic); do { Console.Write("Phone:\n" + entry.GetPhone()); success = entry.SetPhone(EditString(entry.GetPhone())); if (!success) { Console.WriteLine("Phone isn't correct. Try again."); } } while (!success); Console.Write("Country:\n" + entry.Country); entry.Country = EditString(entry.Country); do { Console.Write("Birthday:\n" + entry.GetBirthdayString()); success = entry.SetBirthdayString(EditString(entry.GetBirthdayString())); if (!success) { Console.WriteLine("Phone isn't correct. Try again."); } } while (!success); Console.Write("Company:\n" + entry.Company); entry.Company = EditString(entry.Company); Console.Write("Position:\n" + entry.Position); entry.Position = EditString(entry.Position); Console.Write("Notes:\n" + entry.Notes); entry.Notes = EditString(entry.Notes); Console.ReadKey(true); }