Exemplo n.º 1
0
        static async Task <FetchRowsResult> FetchRowsAsync(FetchPageAsyncEventArgs e)
        {
            IssueSortOrder sortOrder = GetIssueSortOrder(e);
            IssueFilter    filter    = MakeIssueFilter(e.Filter);

            var issues = await IssuesService.GetIssuesAsync(
                page : e.Skip / e.Take,
                pageSize : e.Take,
                sortOrder : sortOrder,
                filter : filter);

            return(new FetchRowsResult(issues, hasMoreRows: issues.Length == e.Take));
        }
        public async static Task <IssuesSummaries> GetSummariesAsync(IssueFilter filter)
        {
            await Task.Delay(300);

            var issues = (IEnumerable <IssueData>)AllIssues.Value;

            if (filter != null)
            {
                issues = FilterIssues(filter, issues);
            }
            var lastCreated = issues.Any() ? issues.Max(x => x.Created) : default(DateTime?);

            return(new IssuesSummaries(count: issues.Count(), lastCreated: lastCreated));
        }
Exemplo n.º 3
0
        static async Task <object[]> GetTotalSummariesAsync(GetSummariesAsyncEventArgs e)
        {
            IssueFilter filter        = MakeIssueFilter(e.Filter);
            var         summaryValues = await IssuesService.GetSummariesAsync(filter);

            return(e.Summaries.Select(x => {
                if (x.SummaryType == SummaryType.Count)
                {
                    return (object)summaryValues.Count;
                }
                if (x.SummaryType == SummaryType.Max && x.PropertyName == "Created")
                {
                    return summaryValues.LastCreated;
                }
                throw new InvalidOperationException();
            }).ToArray());
        }
 static IEnumerable <IssueData> FilterIssues(IssueFilter filter, IEnumerable <IssueData> issues)
 {
     if (filter.CreatedFrom != null || filter.CreatedTo != null)
     {
         if (filter.CreatedFrom == null || filter.CreatedTo == null)
         {
             throw new InvalidOperationException();
         }
         issues = issues.Where(x => x.Created >= filter.CreatedFrom.Value && x.Created < filter.CreatedTo);
     }
     if (filter.MinVotes != null)
     {
         issues = issues.Where(x => x.Votes >= filter.MinVotes.Value);
     }
     if (filter.Priority != null)
     {
         issues = issues.Where(x => x.Priority == filter.Priority);
     }
     return(issues);
 }
        public async static Task <IssueData[]> GetIssuesAsync(int page, int pageSize, IssueSortOrder sortOrder, IssueFilter filter)
        {
            await Task.Delay(300);

            var issues = SortIssues(sortOrder, AllIssues.Value);

            if (filter != null)
            {
                issues = FilterIssues(filter, issues);
            }
            return(issues.Skip(page * pageSize).Take(pageSize).ToArray());
        }