I am trying to pass a javascript object that contains
question(string), multianswers(answer(string),correct(bit)).
This is the value of multianswers -
[{'correct':true,'answer':'A1'}, {'correct':true,'answer':'A2'}];
What type should be the parameter that I am passing to the controller.
function setMultiQuestion(question, responses) {
var responsesList = angular.toJson(responses);
function questionAnswerObj(question, answers)
{
this.question = question;
this.answers = answers;
}
qaObject = new questionAnswerObj(question, responsesList);
$http.post(baseUrl + "Admin/insertMultiAnswers", { data: qaObject })
.success(function (data, status, headers, config) {
$mdDialog.hide();
$mdToast.show(
$mdToast.simple()
.textContent('New question was added.')
.position('top')
.hideDelay(5000)
.theme('success-toast')
);
})
.error(function (data, status, header, config) {
});
}
And this is my controller.
[HttpPost]
public ActionResult insertMultiAnswers(object data)
{
try
{
Console.Write(data);
// data.setMultiAnswer();
Response.StatusCode = 200;
return Content("Sucess");
}
catch (Exception ex)
{
Response.StatusCode = 500;
return Content("Fail");
}
}