Reputation: 11
We are trying to implement a custom service using aspnetboilerplate .NET Core Multi Page Application template. We are receiving an error in index.js file when trying to hit a service method.
Find herewith the code sections for understanding. Any help on this will be really helpful for us.
public interface IMyTaskAppService : IApplicationService
{
Task<List<string>> GetMyTasks(int input);
}
public class MyTaskAppService : IMyTaskAppService
{
private readonly IMyTaskRepository _mytaskRepository;
public MyTaskAppService(IMyTaskRepository mytaskRepository)
{
_mytaskRepository = mytaskRepository;
}
Task<List<string>> IMyTaskAppService.GetMyTasks(int input)
{
return _mytaskRepository.GetMyTasks(input);
}
}
Upvotes: 1
Views: 1170
Reputation: 9634
Add ApplicationService
as a base for your MyTaskAppService
class.
See my code;
public class MyTaskAppService : ApplicationService, IMyTaskAppService
{
private readonly IMyTaskRepository _mytaskRepository;
public MyTaskAppService(IMyTaskRepository mytaskRepository)
{
_mytaskRepository = mytaskRepository;
}
Task<List<string>> IMyTaskAppService.GetMyTasks(int input)
{
return _mytaskRepository.GetMyTasks(input);
}
}
See TaskAppService.
public interface IMyTaskAppService : IApplicationService
{
Task<List<string>> GetMyTasks(int input);
}
See the complete source-code of SimpleTaskSystem
Upvotes: 0
Reputation: 43098
MyTaskAppService
requires at least one public
method:
public class MyTaskAppService : IMyTaskAppService
{
// ...
// Task<List<string>> IMyTaskAppService.GetMyTasks(int input)
public Task<List<string>> GetMyTasks(int input)
{
return null;
}
}
What you have is an explicit implementation that is "more restricted than private".
Service and method names are in camelCase for Client Proxies.
Use an uppercase T
for myTask
:
var _myTaskService = abp.services.app.myTask;
Use a lowercase g
for getMyTasks
:
_myTaskService.getMyTasks({
taskID: taskID
}).done(function (data) {
alert(data);
});
Upvotes: 1