使用Memo類的GetAll接口
總體參照上節(jié)即可
創(chuàng)建MemoService接口
新建文件Mytodo/Service/IMemoService.cs
using MyToDo.Share.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mytodo.Service
{
public interface IMemoService : IBaseService<MemoDto>
{
}
}
實(shí)現(xiàn)MemoService接口
新建文件Mytodo/Service/MemoService.cs
using MyToDo.Share.Contact;
using MyToDo.Share.Models;
using MyToDo.Share.Parameters;
using MyToDo.Share;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mytodo.Service
{
public class MemoService : BaseService<MemoDto>,IMemoService
{
private readonly HttpRestClient client;
public MemoService(HttpRestClient client) : base(client, "Memo")
{
this.client = client;
}
public async Task<ApiResponse<PagedList<MemoDto>>> GetAllFilterAsync(MemoParameter parameter)
{
BaseRequest request = new BaseRequest();
request.Method = RestSharp.Method.Get;
request.Route = $"api/Memo/GetAll?PageIndex={parameter.PageIndex}" +
$"&PageSize={parameter.PageSize}" +
$"&search={parameter.Search}" +
$"&status={parameter.Status}";
return await client.ExecuteAsync<PagedList<MemoDto>>(request);
}
}
}
依賴注入
修改 文件:Mytodo/App.xaml.cs
部分修改為:文章來源:http://www.zghlxwxcb.cn/news/detail-612704.html
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
//注冊服務(wù)
containerRegistry.GetContainer().Register<HttpRestClient>(made: Parameters.Of.Type<string>(serviceKey: "webUrl"));
containerRegistry.GetContainer().RegisterInstance(@"Http://localhost:19007/", serviceKey: "webUrl");
containerRegistry.Register<ITodoService, TodoService>();
containerRegistry.Register<IMemoService, MemoService>();
containerRegistry.RegisterForNavigation<AboutView, AboutViewModel>();
containerRegistry.RegisterForNavigation<SysSetView, SysSetViewModel>();
containerRegistry.RegisterForNavigation<SkinView, SkinViewModel>();
containerRegistry.RegisterForNavigation<IndexView, IndexViewModel>();
containerRegistry.RegisterForNavigation<TodoView, TodoViewModel>();
containerRegistry.RegisterForNavigation<MemoView, MemoViewModel>();
containerRegistry.RegisterForNavigation<SettingsView, SettingsViewModel>();
}
修改ViewModel
參照上節(jié)文章來源地址http://www.zghlxwxcb.cn/news/detail-612704.html
到了這里,關(guān)于WPF實(shí)戰(zhàn)學(xué)習(xí)筆記15-使用Memo類的GetAll接口的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!