I have an array inside javascript for storing all field values and am passing that array to a model property AddChecklistSurveyResult
. After submitting the page am trying to pass this model property as a parameter inside a function SaveLpgResult
while calling service, It's showing Null, Thanks in advance.
MODEL (QAGInspectionViewModel )
public string AddChecklistSurveyResult { get; set; }
HTML
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<table>
<tr>
<td colspan="2">
<button type="submit" class="btn btn-success">Save</button>
</td>
</tr>
</table>
@Html.HiddenFor(model => model.AddChecklistSurveyResult);
}
JAVASCRIPT
function LpgChecklist()
{
$.each(answers, function (index, value) {
surveyIdList = surveyIdObj
surveyTemplateList = surveyTemplateObj
answerList = value.answerListId;
question = value.questionId;
value = value.value;
ChecklistDetails.push({
answerArr: answerList,
QuestionArr: question,
valueArr: value
});
console.log(ChecklistDetails);
$("#AddChecklistSurveyResult").val(JSON.stringify(ChecklistDetails));
});
CONTROLLER
[HttpPost]
public ActionResult _QAGInspectionDetails(QAGInspectionViewModel model)
{
var save = qAGCaseService.Create(model);
}
qAGCaseService (SERVICE)
public bool Create(QAGInspectionViewModel model)
{
SaveLpgResult(model.AddChecklistSurveyResult, model.EntryBy);
//Here Am getting Null for model.AddChecklistSurveyResult
}
Am Expecting result like this:
[
{
"LPG_Brand":"Caltex",
"LPG_Status":null,
"LPG_Capacity":"13.3",
"LPG_Used":"",
"LPG_Unused":"",
"LPG_Quantity":"",
"LPG_Detained":"Yes",
"LPG_StorageLocation":"EMSD",
"LPG_Brand_Display":null,
"LPG_Capacity_Display":null,
"LPG_Detained_Display":null,
"LPG_StorageLocation_Display":null
}
]