This is my ajax call. Before ajax call I am tracking some data from html and pushing all these data to an array. After that I am passing that array to controller through ajax call, but its not working .
ajax call:
$("#moveAllRowsContractprijsGrid").click(function () {
var model = [];
$("#storingBody tr").each(function () {
var myModel = {
Scontractid: $(this).find('td').eq(0).find('input').data('id'),
IssueTypeId: $(this).find('td').eq(1).find('input').data('id'),
StoringsItemId: $(this).find('td').eq(2).find('input').data('id'),
StoringsItem: $(this).find('td').eq(3).text().trim(),
IssueType: $(this).find('td').eq(4).text().trim()
}
model.push(myModel);
});
debugger;
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: 'json',
type: 'POST',
url: '@Url.Action("AddAllStoringItemsInContractprijs", "Storingsitems")',
data: model,
success: function (data) {
},
failure: function (response) {
}
});
});
controller:
public IActionResult AddAllStoringItemsInContractprijs(List<StoringsitemsViewMode> model)
{
//model.Incontract = true;
//var returnModel = model;
//_storingsitemsService.AddAllStoringItemsInContractprijs(model);
//return Json(returnModel);
return null;
}
data transfer objects:
public class StoringsitemsViewMode
{
public int Scontractid { get; set; }
public int IssueTypeId { get; set; }
public string IssueType { get; set; }
public bool? Analyse { get; set; }
public int StoringsItemId { get; set; }
public string StoringsItem { get; set; }
public bool Incontract { get; set; }
}