Beispiel #1
0
        public async static Task <IssuesSummaries> GetSummariesAsync(IssueFilter filter)
        {
            await Task.Delay(300).ConfigureAwait(false);

            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));
        }
Beispiel #2
0
 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);
 }
Beispiel #3
0
        public async static Task <IssueData[]> GetIssuesAsync(int skip, int take, IssueSortOrder sortOrder, IssueFilter filter)
        {
            await Task.Delay(300).ConfigureAwait(false);

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

            if (filter != null)
            {
                issues = FilterIssues(filter, issues);
            }
            return(issues.Skip(skip).Take(take).Select(x => x.Clone()).ToArray());
        }