WPF实战项目十六(客户端):备忘录接口

1、新增IMemoService接口,继承IBaseService接口

    public interface IMemoService : IBaseService
    {
    }

2、新增MemoService类,继承BaseService和IMemoService接口

    public class MemoService : BaseService, IMemoService
    {
        public MemoService(HttpRestClient client) : base(client, "Memo")
        {
        }
    }

3、在App.xmal.cs中注册备忘录的服务

        containerRegistry.Register();

4、在MemoViewModel.cs中添加备忘录的服务

        private readonly IMemoService memoService;
        public MemoViewModel(IMemoService memoService)
        {
            MemoDtos = new ObservableCollection();
            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运行项目

WPF实战项目十六(客户端):备忘录接口_第1张图片

你可能感兴趣的:(.netcore,WPF,wpf,webapi,.netcore,c#)