首页 > 解决方案 > 将对象形式 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:

来自 Angularjs

到 API:

至 API

标签: c#angularjsasp.net-coreasp.net-core-webapi

解决方案


推荐阅读