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.

Overview

The Issues Service is a static class:

public static class IssuesService {
    public async static Task<IssueData[]> GetIssuesAsync(
        int skip, int take, 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 int Id { get; private set; }
    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,
}

The Issues Service allows you to apply the following 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; }
}

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 skip, int take, IssueSortOrder sortOrder, IssueFilter filter) {
    await Task.Delay(300);
    // ...
}
public async static Task<IssuesSummaries> GetSummariesAsync(IssueFilter filter) {
    await Task.Delay(300);
    // ...
}