0
I need to pass the values of a view model, and of a table, the table is passing normally, when passed alone, the viewmodel does not. Go on like I’m doing:
var model1 = objectifyForm(model);
    console.log(model1);
    debugger;
    $.ajax({
        url: '@Url.Action("Novo1", "PedidoFornecedor")',
        type: 'POST',
        dataType: 'json',
        contentType: 'application/json',
        data: { valores: JSON.stringify(valores), model: model1 }
    });
This is the function that takes the form input:
 function objectifyForm(formArray) {//serialize data function
    var returnArray = {};
    for (var i = 0; i < formArray.length; i++) {
        returnArray[formArray[i]['name']] = formArray[i]['value'];
    }
    return returnArray;
}
However in the controller, all the way I try, an empty comes, or does not come with the correct data, how can I proceed?
[HttpPost]
    public IActionResult Novo1([FromBody]List<PedidosProdutosF> valores, NovoViewModel model)
    {
        if (ModelState.IsValid)
        {
						
Mariana you will have to join the two objects in one and send a single object
– Leonardo Bonetti
As well, unite the objects ?
– Mariana
I’ll write an answer
– Leonardo Bonetti
give a look, if it doesn’t work me give details I fix, mainly on the part of creating the new object in c#
– Leonardo Bonetti
can put the Novoviewmodel class and what values are passing in the model1 .
– Cassio Alves