public async Task <ErrorBase> TrySearchCategories(string query, SearchType searchType) { if (!string.IsNullOrEmpty(query) && (query.Length == 1 || (query.Length == 2 && searchType == SearchType.People)) || string.IsNullOrEmpty(query) && searchType == SearchType.People) { if (searchType == SearchType.Tags) { TagsPresenter.NotifySourceChanged(nameof(TrySearchCategories), true); } else { UserFriendPresenter.NotifySourceChanged(nameof(TrySearchCategories), true); } return(null); } if (string.IsNullOrEmpty(query)) { return(await TagsPresenter.TryGetTopTags()); } if (searchType == SearchType.Tags) { return(await TagsPresenter.TryLoadNext(query)); } return(await UserFriendPresenter.TryLoadNextSearchUser(query)); }
public async Task <Exception> TrySearchCategories(string query, SearchType searchType) { try { if (!string.IsNullOrEmpty(query) && (query.Length == 1 || (query.Length == 2 && searchType == SearchType.People)) || string.IsNullOrEmpty(query) && searchType == SearchType.People) { if (searchType == SearchType.Tags) { TagsPresenter.NotifySourceChanged(nameof(TrySearchCategories), true); TagsPresenter.TasksCancel(); } else { UserFriendPresenter.NotifySourceChanged(nameof(TrySearchCategories), true); UserFriendPresenter.TasksCancel(); } return(new ValidationException(LocalizationKeys.TagSearchWarning)); } if (string.IsNullOrEmpty(query)) { return(await TagsPresenter.TryGetTopTags()); } if (searchType == SearchType.Tags) { return(await TagsPresenter.TryLoadNext(query)); } return(await UserFriendPresenter.TryLoadNextSearchUser(query)); } catch (Exception ex) { return(null); } }