Skip to main content
A newer version of this page is available. .

Sample Service for Tutorial

  • 2 minutes to read

This topic describes the Issues Service. This service is used as an example of a data source in this tutorial. The service’s API is similar to the StackExchange Questions API.

This document consists of the following sections:

Overview

The Issues Service is a static class:

public static class IssuesService {
    public async static Task<IssueData[]> GetIssuesAsync(int page, int pageSize, IssueSortOrder sortOrder, IssueFilter filter);
    public async static Task<IssuesSummaries> GetSummariesAsync(IssueFilter filter);
}

GetIssuesAsync Method

The GetIssuesAsync method returns a task that allows you to get a page with the following data:

public class IssueData {
    public string Subject { get; private set; }
    public string User { get; private set; }
    public DateTime Created { get; private set; }
    public int Votes { get; private set; }
    public Priority Priority { get; private set; }
}

The Issues Service allows you to apply the following sort orders

public enum IssueSortOrder {
    Default,
    CreatedDescending,
    VotesAscending,
    VotesDescending,
}

… and filters:

public class IssueFilter {
     public Priority? Priority { get; private set; }
     public DateTime? CreatedFrom { get; private set; }
     public DateTime? CreatedTo { get; private set; }
     public int? MinVotes { get; private set; }
}

GetSummariesAsync Method

The GetSummariesAsync method returns a task that allows you to get a total count of rows and the last created object’s datetime:

public class IssuesSummaries {   
    public int Count { get; private set; }
    public DateTime? LastCreated { get; private set; }
}

A filter is taken into account.

Miscellaneous

The Issues Service returns data with a delay to show a loading indicator when fetching data:

VirtualSourcesLoadingPanel

public async static Task<IssueData[]> GetIssuesAsync(int page, int pageSize, IssueSortOrder sortOrder, IssueFilter filter) {
    await Task.Delay(300);
    // ...
}
public async static Task<IssuesSummaries> GetSummariesAsync(IssueFilter filter) {
    await Task.Delay(300);
    // ...
}