c# - 将对象形式 angularjs 发送到 API .net 核心总是 id=0
问题描述
我正在尝试将一个对象从 angularjs 发送到 API .net 核心。一切都很好,但 id,在角度上它是它的值,但在 API 中它总是 0(零)。对象中的每个 id 都是 0(零)。
来自angularjs的代码:
vm.editReservation = function editReservation() {
reservationService.editReservation(vm.reservation).then(function(result) {
toastr.options = { "positionClass": "toast-top-full-width" };
toastr.success("Ruajtja u krye me sukses");
}).catch(function (response) {
toastr.options = { "positionClass": "toast-top-full-width" };
toastr.error(response.message);
});
};
来自 API .net 核心的代码:
[HttpPost("editReservation")]
public async Task<IActionResult> EditReservation([FromBody] Models.Reservation reservation)
{
Models.Reservation modelReservation;
ReservationDuration modelReservationDuration;
ReservationLocation modelReservationLocation;
Person client;
TaxRate taxRate;
string textMessage;
try
{
//some code here
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
我希望 reservation.id = {any number} 但实际是 {0}
来自 Angularjs:
到 API:
解决方案
推荐阅读
- r - 将字符 YYYY-Q1 变成日期
- python - 根据 DataFrame 中多列的条件选择行
- kotlin - 如何正确地对简单字符串值的响应式响应进行单元测试?
- python - Python正则表达式域名
- vue.js - axios Post 根据请求给出 net::ERR_UNEXPECTED_PROXY_AUTH 错误
- sql - 在日期死亡后查找第一笔交易
- javascript - 无法在 jQuery 的 ajax 成功中分配或访问当前选择框值
- css - 相同的 CSS 在具有 Chrome 的两台 PC 上具有不同的行为
- python - 在 sqlite3 中减少读取数据库冗余的功能
- javascript - 根据包括键名在内的值进行排序