1、新增IMemoService接口,继承IBaseService接口
public interface IMemoService : IBaseService<MemoDto>
{
}
2、新增MemoService类,继承BaseService和IMemoService接口
public class MemoService : BaseService<MemoDto>, IMemoService
{
public MemoService(HttpRestClient client) : base(client, "Memo")
{
}
}
3、在App.xmal.cs中注册备忘录的服务
containerRegistry.Register<IMemoService, MemoService>();
4、在MemoViewModel.cs中添加备忘录的服务
private readonly IMemoService memoService;
public MemoViewModel(IMemoService memoService)
{
MemoDtos = new ObservableCollection<MemoDto>();
AddCommand = new DelegateCommand(Add);
this.memoService = memoService;
CreateMemoList();
}
5、重新编写获取备忘录信息代码,CreateMemoList
private async void CreateMemoList()
{
var memoResult = await memoService.GetAllPageListAsync(new WPFProjectShared.Parameters.QueryParameter { PageIndex = 0, PageSize = 100 });
if (memoResult.Status)
{
memoDtos.Clear();
foreach (var item in memoResult.Result.Items)
{
memoDtos.Add(item);
}
}
}
6、F5运行项目