文章目录
使用Todo类的GetAll接口
添加包:RestSharp(V:110)
删除不再需要的文件
- Mytodo/Common/TodoDto.cs
- Mytodo/Common/MemoDto.cs
新建基础类或接口
MyToDo.Share/ApiResponse.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyToDo.Share
{
public class ApiResponse
{
public string? Message { get; set; }
public bool Status { get; set; }
public object? Result { get; set; }
}
public class ApiResponse<T>
{
public string? Message { get; set; }
public bool Status { get; set; }
public T? Result { get; set; }
}
}
MyToDo.Share/IPageList.cs
namespace MyToDo.Share.Contact
{
using System.Collections.Generic;
/// <summary>
/// Provides the interface(s) for paged list of any type.
/// 为任何类型的分页列表提供接口
/// </summary>
/// <typeparam name="T">The type for paging.分页的类型</typeparam>
public interface IPagedList<T>
{
/// <summary>
/// Gets the index start value.
/// 获取索引起始值
/// </summary>
/// <value>The index start value.</value>
int IndexFrom { get; }
/// <summary>
/// Gets the page index (current).
/// 获取页索引(当前)
/// </summary>
int PageIndex { get; }
/// <summary>
/// Gets the page size.
/// 获取页面大小
/// </summary>
int PageSize { get; }
/// <summary>
/// Gets the total count of the list of type <typeparamref name="T"/>
/// 获取类型列表的总计数
/// </summary>
int TotalCount { get; }
/// <summary>
/// Gets the total pages.
/// 获取页面总数
/// </summary>
int TotalPages { get; }
/// <summary>
/// Gets the current page items.
/// 获取当前页项
/// </summary>
IList<T> Items { get; }
/// <summary>
/// Gets the has previous page.
/// 获取前一页
/// </summary>
/// <value>The has previous page.</value>
bool HasPreviousPage { get; }
/// <summary>
/// Gets the has next page.
/// 获取下一页
/// </summary>
/// <value>The has next page.</value>
bool HasNextPage { get; }
}
}
MyToDo.Share/PageList.cs
新建BaseRequest
新建文件:Mytodo/Service/BaseRequest.cs
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mytodo.Service
{
public class BaseRequest
{
public Method Method { get; set; }
public string? Route { get; set; }
public string ContentType { get; set; } = "application/json";