public async Task <SearchOfficeDocumentsResult> Search(SearchDocumentsParameter parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } using (var serviceScope = _serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope()) { using (var context = serviceScope.ServiceProvider.GetService <DocumentManagementDbContext>()) { IQueryable <OfficeDocument> officeDocuments = context.OfficeDocuments; if (!string.IsNullOrWhiteSpace(parameter.Subject)) { officeDocuments = officeDocuments.Where(o => o.Subject == parameter.Subject); } var count = await officeDocuments.CountAsync().ConfigureAwait(false); var content = await officeDocuments.OrderByDescending(d => d.UpdateDateTime).Skip(parameter.StartIndex).Take(parameter.Count).Select(s => s.ToDomain()).ToListAsync().ConfigureAwait(false); return(new SearchOfficeDocumentsResult { Content = content, Count = count }); } } }
public Task <SearchOfficeDocumentsResult> Execute(SearchDocumentsParameter parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } return(_officeDocumentRepository.Search(parameter)); }
public Task <SearchOfficeDocumentsResult> Search(SearchDocumentsParameter parameter) { return(_searchOfficeDocumentsAction.Execute(parameter)); }