In the following sample of code I send a "request" and I am trying to get a response but that returns "undefined" value. This is my code so far
$scope.SameNameFunction = function() {
var payload = { itemname: $scope.EventDetails.Name};
portalRepository.namecall(payload).then(function (payload) {
console.log(payload.valuesreturned);
alert("Detected: " + payload.valuesreturned + " events having the same name");
});
};
Code from the http.post
namecall: function (payload) {
return $http.post("/Api/PortalData/NameNumberResult", payload);
},
Code from the .cs controller:
public ActionResult NameNumberResult(ItemEventNameDTO payload)
{
var valuetosend = payload.itemname;
var acf = new AcFunctions();
var newstorevalue = SqlHelper.ExecuteDataset(acf.AcConn(), "sp_selectbyname", valuetosend);
payload.valuesreturned = newstorevalue.Tables[0].Rows.Count;
return payload.GetSuccess();
}
Putting a breakpoint I am getting the appropriate value from the stored procedure, either in .cs and .js files. But while trying to print the message in screen, value do not appear and "Detected undefined events having the same name" is showing instead. Any help is welcome!
portalRepository.namecall?