public IReadOnlyList <Tuple <int, PhoneBook.Note> > AcquireNotesByNameOrPhone(bool isEscapeAllowed) { UserDialog.DisplayOptions(nameOrPhoneMenu, "Enter option", isEscapeAllowed ? "To escape" : null); IReadOnlyList <Tuple <int, PhoneBook.Note> > notes = null; switch (UserDialog.AcquireCommandInRange(0, 1, isEscapeAllowed)) { case ESCAPE_VAL: notes = null; break; case 0: string surname; string name; AcquireSurnameAndName(out surname, out name); notes = phoneBook.GetNotes(surname, name); break; case 1: string phoneNumber = AcquirePhoneNumberToCheck(); notes = phoneBook.GetNotes(phoneNumber); break; } return(notes); }
public IReadOnlyList <Tuple <int, PhoneBook.Note> > AcquireNoteOfEqual(IReadOnlyList <Tuple <int, PhoneBook.Note> > notes, bool isEscapeAllowed) { if (notes == null) { throw new ArgumentOutOfRangeException("not allowed to send null list"); } Console.WriteLine("List contains several equal Notes:"); DisplayShortInfo(notes); Console.Write("Enter ID to perform action "); if (isEscapeAllowed) { Console.Write($"or {ESCAPE_VAL} to escape"); } Console.WriteLine(); int idx = UserDialog.AcquireCommandInRange(notes.First().Item1, notes.Last().Item1, isEscapeAllowed); if (idx == ESCAPE_VAL) { return(null); } return(notes.Where(x => x.Item1 == idx).ToList()); }