Skip to main content

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. Its 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<string[]> GetTagsAsync();
}

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 string[] Tags { get; private set; }
}

The Issues Service allows you to apply the following sort orders

public enum IssueSortOrder {
    Default,
    Hot,
    Week,
    CreatedAscending,
    CreatedDescending,
    VotesAscending,
    VotesDescending,
}

… and filters:

public class IssueFilter {
    public DateTime? CreatedFrom { get; private set; }
    public DateTime? CreatedTo { get; private set; }
    public int? MinVotes { get; private set; }
    public int? MaxVotes { get; private set; }
    public string Tag { get; private set; }
}

GetTagsAsync Method

The GetTagsAsync method returns a task that allows you to get a list of tags:

VirtualSourcesAdvancedTutorialTags

Service Restrictions

The Issues Service has the following restrictions:

  • Hot and Week sort orders can be filtered by Tags only.
  • You can filter by Votes only after sorting by Votes.

An error occurs if you make a request that violates the restrictions above.

Miscellaneous

To display a loading indicator during fetch operations, the Issues Service returns data with a short time delay:

VirtualSourcesLoadingPanel

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