Ejemplo n.º 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));
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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());
        }