コード例 #1
0
        public async Task <ProductVideoSearchResult> SearchVideoLinksAsync(ProductVideoSearchCriteria criteria)
        {
            var cacheKey = CacheKey.With(GetType(), nameof(SearchVideoLinksAsync), criteria.GetCacheKey());

            return(await _platformMemoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) =>
            {
                cacheEntry.AddExpirationToken(ProductVideoCacheRegion.CreateChangeToken());
                var result = AbstractTypeFactory <ProductVideoSearchResult> .TryCreateInstance();

                using (var repository = _repositoryFactory())
                {
                    var query = repository.VideoLinks.Where(x => criteria.ProductIds.Contains(x.ProductId));

                    result.TotalCount = await query.CountAsync();

                    if (criteria.Take > 0)
                    {
                        var videoLinksIds = await query.OrderByDescending(x => x.CreatedDate).Skip(criteria.Skip)
                                            .Take(criteria.Take)
                                            .Select(x => x.Id)
                                            .ToArrayAsync();

                        var priorResults = await _productVideoService.GetByIdsAsync(videoLinksIds);
                        //TODO warning EF1001: Microsoft.EntityFrameworkCore.Internal.EnumerableExtensions is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs.
                        result.Results = priorResults;
                    }

                    return result;
                }
            }));
        }
コード例 #2
0
        public virtual async Task <IList <IndexDocument> > GetDocumentsAsync(IList <string> documentIds)
        {
            var categories = await _productVideoService.GetByIdsAsync(documentIds.ToArray());

            IList <IndexDocument> result = categories
                                           .Select(CreateDocument)
                                           .Where(doc => doc != null)
                                           .ToArray();

            return(result);
        }
コード例 #3
0
 //[CheckPermission(Permission = Core.ModuleConstants.Security.Permissions.Read)]
 public async Task <IActionResult> GetById([FromRoute] string id) => Ok(await _productVideoService.GetByIdsAsync(new string[] { id }));