Ejemplo n.º 1
0
        public async Task <IEnumerable <SearchFacetItem> > GetGroupedCitiesAsync(
            CancellationToken cancellationToken)
        {
            IEnumerable <BsonDocument> docs = await _mediaStoreContext.ExecuteAggregation(
                CollectionNames.Media,
                "Media_GroupByCity",
                cancellationToken);

            var result = new List <SearchFacetItem>();

            foreach (BsonDocument doc in docs)
            {
                var item = new SearchFacetItem();
                item.Count = doc["count"].AsInt32;

                if (doc["_id"].IsString)
                {
                    item.Text  = doc["_id"].AsString;
                    item.Value = doc["_id"].AsString;
                    result.Add(item);
                }
            }

            return(result.OrderByDescending(x => x.Count));
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <SearchFacetItem> > GetGroupedAITagsAsync(
            CancellationToken cancellationToken)
        {
            IEnumerable <BsonDocument> docs = await _mediaStoreContext.ExecuteAggregation(
                CollectionNames.MediaAI,
                "MediaAI_GroupByTag",
                cancellationToken);

            var result = new List <SearchFacetItem>();

            foreach (BsonDocument doc in docs)
            {
                var item = new SearchFacetItem();
                item.Count = doc["count"].AsInt32;

                if (doc["_id"].IsString)
                {
                    item.Value = doc["_id"].AsString;
                    item.Text  = TitleCase(item.Value.Replace("_", " "));
                    result.Add(item);
                }
            }

            return(result);
        }