Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
 public async Task <Maybe <PagedResult <Tag> > > BrowseTagsAsync(BrowseRemarkTags query)
 => await _provider.GetCollectionAsync(
     async() => await _tagRepository.BrowseAsync(query),
     async() => await _serviceClient.BrowseTagsAsync <Tag>(query));