I have a class PreventivoDS
public class PreventivoDS
{
public int Id { get; set; }
public string? CodPreventivo { get; set; }
public string Data { get; set; }
public int Durata { get; set; }
public int IdCliente { get; set; }
public string Cliente { get; set; }
public string Descrizione { get; set; }
public string Oggetto { get; set; }
public int IdCondizionePagamento { get; set; }
public string CondizionePagamento { get; set; }
public decimal CostoSpedizione { get; set; }
public bool? Accettazione { get; set; }
public string? DataRisposta { get; set; }
public IFormFile FilePreventivoAccettato { get; set; }
public List<PreventivoArticoloDettaglioDS> PreventivoArticoloDettaglio { get; set; }
public List<PreventivoPagamentoDS> PreventivoPagamento { get; set; }
}
Class PreventivoArticoloDettaglioDS
public class PreventivoArticoloDettaglioDS
{
//CODE HERE
}
Class PreventivoPagamentoDS
public class PreventivoPagamentoDS
{
//CODE HERE
}
And the controller with
[HttpPost]
public async Task<AnagResult<PreventivoDS>> AddEditPreventivo([FromForm] PreventivoDS p)
{
//CODE HERE...
}
But passing the formdata via ajax the lists PreventivoArticoloDettaglioDS and PreventivoPagamentoDS are always empty. This is my JavaScript code
$.ajax({
url: '/Preventivi/AddEditPreventivo',
data: formData,
type: "POST",
contentType: false,
processData: false,
beforeSend: function (event) {
loadingPage("Attendere!!! Salvataggio Preventivo in Corso...");
},
success: function (mydata) {
.....
},
complete: function (event, jqXHR, ajaxOptions) {
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
}
});
});
I want to know why these 2 lists are always empty:
When data is passed to the back end the main object PreventivoDS always has empty lists
when ajax passes the formdata object to the backend inside the object there are all the data except the 2 lists which are always with zero records. Who can help me?