跟进,而不是任务codeproject.com
我加入了简单的实体(客户端)的任务创建者的应用程序执行。
任务的显示工作正常。然而,当我尝试添加一个新的客户端似乎动态API是不可用,我收到以下错误:
ClientsController:
`[AbpMvcAuthorize] 公共类ClientsController:MyAppControllerBase 私有只读IClientAppService _clientService;
public ClientsController(IClientAppService clientService)
{
_clientService = clientService;
}
public async Task Index(GetAllClientsInput input)
{
var output = await _clientService.GetAll(input);
var model = new Web.Models.Clients.IndexViewModel(output.Items);
return View("Index", model);
}
public async Task Create(CreateClientInput input)
{
await _clientService.Create(input);
}
public async Task Delete(CreateClientInput input)
{
await _clientService.Create(input);
}
}`
Index.js:
(function() {
$(function() {
var _clientService = abp.services.app.client;
var _$modal = $('#ClientCreateModal');
var _$form = _$modal.find('form');
_$form.validate();
_$form.find('button[type="submit"]').click(function (e) {
e.preventDefault();
if (!_$form.valid()) {
return;
}
var client = _$form.serializeFormToObject(); //serializeFormToObject is defined in main.js
abp.ui.setBusy(_$modal);
_clientService.create(client).done(function() {
_$modal.modal('hide');
location.reload(true); //reload page to see new user!
}).always(function() {
abp.ui.clearBusy(_$modal);
});
});
_$modal.on('shown.bs.modal', function() {
_$modal.find('input:not([type=hidden]):first').focus();
});
});
})();
Index.cshtml
@section scripts
{
}
客户服务:
[AbpAuthorize(PermissionNames.Pages_Tenants)]
public class ClientAppService : ApplicationService, IClientAppService
{
private readonly IRepository _clientRepository;
public ClientAppService(IRepository clientRepository)
{
_clientRepository = clientRepository;
}
public async Task> GetAll(GetAllClientsInput input)
{
var clients = await _clientRepository
.GetAll().ToListAsync();
return new ListResultDto(
ObjectMapper.Map>(clients));
}
public async Task Create(CreateClientInput input)
{
var task = ObjectMapper.Map(input);
await _clientRepository.InsertAsync(task);
}
}
服务器不被打到在所有的创建行动。
任何想法我失踪?
2017-10-07
akd
+0
您可以检查错误日志中'* .Web.Mvc \ App_Data文件\ Logs'? –
+0
非常感谢。日志文件告诉了很多。客户端实现IMustHaveTenant。并且当我以主机用户的身份登录时,错误显示“无法为IMustHaveTenant实体将TenantId设置为0!”我希望我能看到该警告,而不是发生内部服务器错误! –
+0
那么,这是一个编程错误,客户端不应该可见。 –