private async Task <IPagedResults <File> > GetResultsAsync(EntityFileOptions model) { IEnumerable <EntityFile> relaationships = null; if (model.EntityId > 0) { relaationships = await _entityAttachmentStore .GetByEntityIdAsync(model.EntityId); } return(await _attachmentStore .QueryAsync() .Take(int.MaxValue, false) .Select <FileQueryParams>(q => { // Get attachments for entity if (relaationships != null) { q.Id.IsIn(relaationships.Select(r => r.FileId).ToArray()); } // Get attachments for guid q.ContentGuid.Equals(model.Guid).Or(); }) .OrderBy("TotalViews", OrderBy.Desc) .ToList()); }
public async Task <IViewComponentResult> InvokeAsync(IEntity entity, IEntityReply reply) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(View(new EntityFilesViewModel() { Results = await _entityAttachmentStore.GetByEntityIdAsync(entity.Id) })); }