public Task <DelegateConfigurationResult> GetResult(string delegateId, CancellationToken cancellationToken) { var result = _delegateConfigurationAggregates.FirstOrDefault(_ => _.AggregateId == delegateId); if (result == null) { return(Task.FromResult((DelegateConfigurationResult)null)); } return(Task.FromResult(DelegateConfigurationResult.ToDto(result))); }
public async Task <DelegateConfigurationResult> GetResult(string delegateId, CancellationToken cancellationToken) { var result = await _dbContext.DelegateConfigurations.FirstOrDefaultAsync(d => d.AggregateId == delegateId, cancellationToken); if (result == null) { return(null); } return(DelegateConfigurationResult.ToDto(result)); }
public Task <SearchResult <DelegateConfigurationResult> > Search(SearchDelegateConfigurationQuery parameter, CancellationToken cancellationToken) { IQueryable <DelegateConfigurationAggregate> result = _delegateConfigurationAggregates.AsQueryable(); if (MAPPING_DELEGATECONFIGURATION_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy)) { result = result.InvokeOrderBy(MAPPING_DELEGATECONFIGURATION_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order); } int totalLength = result.Count(); result = result.Skip(parameter.StartIndex).Take(parameter.Count); var content = result.ToList(); content = content.OrderByDescending(r => r.Version).GroupBy(r => r.AggregateId).Select(r => r.First()).ToList(); return(Task.FromResult(new SearchResult <DelegateConfigurationResult> { StartIndex = parameter.StartIndex, Count = parameter.Count, TotalLength = totalLength, Content = content.Select(_ => DelegateConfigurationResult.ToDto(_)).ToList() })); }