I have two class and basically I am trying to call two separate models with two store procedures to insert data in both table. I wrote my controller like this:
[HttpPost]
public IHttpActionResult Adddata([FromBody]IList<Details> details,[FromBody] Request request)
{
var changerequestResponse = db.sp_AddChangerequests(request.EmpID, request.CreatedDate, request.Status).SingleOrDefault();
GenericResponse objResponse = null;
foreach (Details detail in detailss)
{
var data = JsonConvert.SerializeObject(db.sp_AddChangerequestDetails(detailss.CRID, detailss.Category, detailss.Info, detailss.Col, detailss.Reason).SingleOrDefault(), Formatting.Indented, settings);
objResponse = JsonConvert.DeserializeObject<GenericResponse>(data);
}
return Ok(objResponse);
}
and my controller js file like this:
$scope.SubmitrequestForm = function(){
console.log($scope.changereqcol);
var req = {
method: 'POST',
url: WebApiUrl + 'Adddata',
headers: {
'Content-Type': 'application/json'
},
data: JSON.stringify($scope.changereqcol)
}
console.log()
$http(req).then(function (data, status) {
console.log(data);
}, function (err, status) {
console.log(err);
});
};
when I am trying to submit the data I am getting above error. Can you please tell me what I am missing