public Task <FindResponse <NotificationDefinitionAggregate> > Search(SearchNotificationDefParameter parameter, CancellationToken token) { IQueryable <NotificationDefinitionAggregate> result = _notifications.AsQueryable(); if (!string.IsNullOrWhiteSpace(parameter.Name)) { result = result.Where(_ => _.Name == parameter.Name); } if (MAPPING_NOTIFICATIONDEF_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy)) { result = result.InvokeOrderBy(MAPPING_NOTIFICATIONDEF_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order); } int totalLength = result.Count(); result = result.Skip(parameter.StartIndex).Take(parameter.Count); return(Task.FromResult(new FindResponse <NotificationDefinitionAggregate> { StartIndex = parameter.StartIndex, Count = parameter.Count, TotalLength = totalLength, Content = result.ToList() })); }
public async Task <FindResponse <NotificationDefinitionAggregate> > Search(SearchNotificationDefParameter parameter, CancellationToken token) { IQueryable <NotificationDefinitionAggregate> result = _dbContext.NotificationDefinitions .Include(_ => _.OperationParameters) .Include(_ => _.PresentationElements) .Include(_ => _.PeopleAssignments) .Include(_ => _.PresentationParameters);; if (!string.IsNullOrWhiteSpace(parameter.Name)) { result = result.Where(_ => _.Name == parameter.Name); } if (MAPPING_NOTIFICATIONDEF_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy)) { result = result.InvokeOrderBy(MAPPING_NOTIFICATIONDEF_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order); } int totalLength = await result.CountAsync(token); result = result.Skip(parameter.StartIndex).Take(parameter.Count); return(new FindResponse <NotificationDefinitionAggregate> { StartIndex = parameter.StartIndex, Count = parameter.Count, TotalLength = totalLength, Content = await result.ToListAsync(token) }); }