将对象形式的angularjs发送到API .net core始终是id = 0

时间:2019-04-24 19:44:57

标签: c# angularjs asp.net-core asp.net-core-webapi

我正在尝试将一个对象从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:

From Angularjs

致API:

To API

0 个答案:

没有答案