public Task<IList<object>> ProvideSuggestions(string enteredText)
{
switch (PatchOn)
{
case PatchOnOptions.Document:
return ApplicationModel.Database.Value.AsyncDatabaseCommands.StartsWithAsync(SelectedItem, 0, 25, metadataOnly: true)
.ContinueWith(t => (IList<object>) t.Result.Select(d => d.Key).Cast<object>().ToList());
case PatchOnOptions.Collection:
return ApplicationModel.Current.Server.Value.SelectedDatabase.Value.AsyncDatabaseCommands.GetTermsCount(
CollectionsIndex, "Tag", "", 100)
.ContinueOnSuccess(collections => (IList<object>)collections.OrderByDescending(x => x.Count)
.Where(x => x.Count > 0)
.Select(col => col.Name).Cast<object>().ToList());
case PatchOnOptions.Index:
return ApplicationModel.Database.Value.AsyncDatabaseCommands.GetIndexNamesAsync(0, 500)
.ContinueWith(t => (IList<object>) t.Result.Where(s => s.StartsWith(enteredText, StringComparison.OrdinalIgnoreCase)).Cast<object>().ToList());
default:
return null;
}
}