How can I ensure that the nested object values in the parameter are passed correctly to the action method in the controller along with the full object?
When calling the AJAX method, the values in the object inside the red ring on the pictures do not get passed to the controller.
mapHub.client.requestForHelpInClient = function (requestDetails) {
debugger;
$.ajax({
type: "GET",
url: '@Url.Action("RequestPartialView", "Supplier")',
data: requestDetails,
success: function (response) {
$("#Request").html(response);
},
error: function (error) {
console.log(error);
}
});
}
https://i.stack.imgur.com/1HCaP.png
function requestForHelp() {
requestDetails = {
CustomerId: @Model.Customer.CustomerID,
NumberOfHours: $("#numberOfHoursTextBox").val(),
TypeOfMachine: $("#typeOfMachineDropDownMenu").children("option:selected").val(),
CustomerLocation: CustomerPosition,
NearestSupplierList: nearestSuppliers
//StartDate: $( "#startDate" ).val(),
//EndDate: $( "#endDate" ).val(),
}
mapHub.server.requestForHelp(requestDetails);
public class RequestDetails
{
public int CustomerId { get; set; }
public Customer Customer { get; set; }
public MapClient CustomerLocation { get; set; }
public int NumberOfHours { get; set; }
public string TypeOfMachine { get; set; }
public List<MapClient> NearestSupplierList { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
The signalr hub
public void RequestForHelp(RequestDetails requestDetails)
{
requestDetails.Customer = Service.CustomerService.GetCustomerById(requestDetails.CustomerId);
Service.SupplierService.GetAspNetUserIDBySupplierID(requestDetails.NearestSupplierList[0].ClientId);
Clients.User(supplierAspNetUserID).requestForHelpInClient(requestDetails);
}