I'm having trouble understanding this:
When I click on the Datatable
line to edit the Client data, an error occurs whenever the Client has a Contact or a Registered Address and this is very common.
This is code that is triggered when I double click on the Datatable
line:
VIEW
// BUSCA DETALHES DO CLIENTE
$.ajax({
url: "ObterClientePorId",
type: "post",
datatype: "json",
contentType: "application/json charset=uft-8",
data: JSON.stringify({ "id": id }),
success: function (data) {
if (data != null) {
alert("Nome: " + data.Result.NMCLIENTE);
var url = "Create?id=" + id;
window.location.href = url;
}
},
error: function (xhr, err) {
alert(err.message);
}
});
Controller:
public JsonResult ObterClientePorId(int id)
{
var ocliente = _IRepositorio.ListarClientePorId(id);
return Json(new { Result = ocliente }, JsonRequestBehavior.AllowGet);
}
Repository:
public TBCliente ListarClientePorId(int? id)
{
return _repositorio.Clientes.FirstOrDefault(c => c.TBCLIENTEID == id);
}
EXECUTION PRINT:
View:
Controller:
Repository:
Controller
NotethattheClienthasaRegisteredAddress
View:
Heretheerroroccurs,alwayswhentheClienthasanAddressoraContactthatiscommon:
Thankyou!
**Doubleclickerror**