public override IReadOnlyCollection <Contact> FindByField(Contact.FieldKind fieldKind, string query) { Console.WriteLine($"Searching contacts by {Contact.GetFieldKindName(fieldKind)} at {BaseUri}"); if (!DoHttpReqeust(httpClient.GetAsync(new Uri(BaseUri, $"/api/findBy?field={fieldKind}&query={query}")), out string response)) { Console.WriteLine(response); return(new ReadOnlyCollection <Contact>(new List <Contact> { })); } List <Contact> parsed = Contact.ParseMany(response, out int parsedCounter, out int totalCounter); Console.WriteLine(IO.ComposeSummaryString("parsed", parsedCounter, totalCounter)); return(new ReadOnlyCollection <Contact>(parsed)); }
private static void SearchByField(Contact.FieldKind fieldKind, IContactsStorage storage) { string query; if (fieldKind != Contact.FieldKind.Birthday) { query = IO.ReadString(Contact.GetFieldKindName(fieldKind) + " substring: "); } else { query = IO.ReadBirthday(); } IO.PrintContactList( searchResultsHeader, storage.FindByField(fieldKind, query) ); }
public List <ContactData> FindBy(Contact.FieldKind fieldKind, string query) { return(ContactData.NewFromContactCollection(storage.FindByField(fieldKind, query))); }
public abstract IReadOnlyCollection <Contact> FindByField(Contact.FieldKind fieldKind, string query);