public async Task SeedAsync() { if (await _database.Remarks().AsQueryable().AnyAsync() == false) { var index = new IndexKeysDefinitionBuilder <Remark>().Geo2DSphere(x => x.Location); await _database.Remarks().Indexes.CreateOneAsync(index); } if (await _database.RemarkCategories().AsQueryable().AnyAsync() == false) { var categories = await _remarkServiceClient .BrowseCategoriesAsync <RemarkCategory>(new BrowseRemarkCategories { Results = int.MaxValue }); if (categories.HasValue) { await _database.RemarkCategories().InsertManyAsync(categories.Value.Items); } } if (await _database.Tags().AsQueryable().AnyAsync() == false) { var tags = await _remarkServiceClient .BrowseTagsAsync <Models.Remarks.Tag>(new BrowseTags { Results = int.MaxValue }); if (tags.HasValue) { await _database.Tags().InsertManyAsync(tags.Value.Items); } } }
public async Task <Maybe <PagedResult <RemarkCategory> > > BrowseCategoriesAsync(BrowseRemarkCategories query) { var categories = await _provider.GetCollectionAsync( async() => await _categoryRepository.BrowseAsync(query), async() => await _serviceClient.BrowseCategoriesAsync <RemarkCategory>(query)); if (categories.HasNoValue) { return(null); } return(PagedResult <RemarkCategory> .From(categories.Value, categories.Value.Items.Reverse())); }