我想获得特定客户的特定保险。当我使用下面的代码到达url {clientId} / insurances / {insuranceId}时。我最终得到404错误。我怎么能解决它?我使用的是正确的方法吗?
[HttpGet("{clientId}/insurances/{insuranceId}")]
public IActionResult Get(int clientId, int insuranceId)
{
var insurances = context.PatientIntakeInsurances.SingleOrDefault(i => i.insurance_id == insuranceId);
if (insurances == null)
return HttpNotFound();
return new ObjectResult(insurances);
}
**这是我的javascript代码
state("clients.detail.insurances.detail", {
url: "/{insuranceId:[0-9]{1,10}}",
templateUrl: "clients/clients.detail.insurances.detail.html",
controller: ("$scope", "$log", "clientsService", "$stateParams",
function ($scope, $log, clientsService, $stateParams)
{
clientsService.getInsurance($stateParams.clientId,$stateParams.insuranceId,
function (insurances)
{
$scope.insurances = insurances;
})
}
**这是我的服务
getInsurance: function(clientId, insuranceId, callback){
$http({
method: "GET",
url: "/api/clients/" +clientId +"/insurances/" + insuranceId
// url: "/api/insurances/" + id
}).then(function(response){
if(typeof callback === "function")
callback(response.date);
}, function(response){
});
},