Код c # для меня не изменился, поэтому вы можете оставить свой как есть.
Что касается вызова aJax,
удаляет dataType, contentType и JSON.stringify ().Мой ниже.
Я создал Модель Времени из того, что ты мне дал.Я надеюсь, что я получил правильные типы данных
public class Time
{
public int Day { get; set; }
public string Code { get; set; }
public string Room { get; set; }
public bool ViewOnSchedual { get; set; }
}
JavaScript:
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
function GetTimes() {
var arr = [];
for (var i = 10; i--;) {
var d = new Date();
arr.push({
Day: getRandomInt(365),
Period: "abc_" + i,
Room: "room_" + i,
ViewOnSchedual: (i % 2 === 0) ? true : false
})
}
return arr;
}
$("#put_time").off().on("click", function () {
var times = GetTimes();
$.ajax({
url: "/Home/UpdateTimes",
type: "PUT",
data: {"times": times},
success: function (data) {
console.log("success")
console.log(data);
},
error: function (x, y, z) {
console.error("there was an error")
console.log(x, y, z)
}
});
})