This is my javascript function to pass data from view to controller:
function UpdateCourse() {
debugger
SelectedIncharge();
SelectedAssistants();
SelectedParticipants();
var Course = $("form").serialize();
var model = {
courseData: Course,
SelectedInchargeList: SelectedInchargeList,
SelectedAssistantList: SelectedAssistantList,
SelectedParticipantList: SelectedParticipantList
};
debugger
$.ajax({
url: '@Url.Action("UpdateCourseDetails", "Course")',
type: 'POST',
dataType: 'JSON',
data: model,
// contentType: "application/json",
success: function (data) {
$('#CoursesSaveBtn').prop("disabled", false);
ShowStatus(data.Response);
hideWait();
GetCourseGrid();
},
error: function (xhr) {
$('#CoursesSaveBtn').prop("disabled", false);
var response = { "ResponseCode": 99, "ResponseMessage": "Validation Failed" };
var responseCode = JSON.parse(JSON.stringify(response));
ShowStatus(responseCode);
hideWait();
}
});
}
I am getting values in the model variable but i get only list correctly the courseData remains null. Here is my code of the view model.
public class CourseModel
{
//public Guid Id { get; set; }
//public string Name { get; set; }
//public string Description { get; set; }
//public string ClassRoom { get; set; }
//public DatabaseOperationType Operation { get; set; }
public CourseRequestDto courseData { get; set; }
public List<Guid> SelectedInchargeList { get; set; }
public List<Guid> SelectedAssistantList { get; set; }
public List<Guid> SelectedParticipantList { get; set; }
}
And my controller definition is as follows:
[HttpPost]
public ActionResult UpdateCourseDetails(CourseModel model)
{
}