I'm having a problem by where I am posting an object to an MVC Core controller from a simple angularjs page.
The object at my MVC action is not binding although the object itself isn't null which is the usual problem with this.
Can anyone see what I am doing wrong?
This is my angular service code:
this.getQuote = function (priceRequest) {
return $http.post('/quote/getcost', { priceRequest });
};
which is called by:
quoteService.getQuote(this.quoteData).then(function (cost) {
$scope.quoteData.quoteCost = cost.data;
});
where this.quoteData is:
$scope.quoteData = {
detailLevel: '0',
fileLengthHours: 0,
fileLengthMinutes: 1,
excessiveSpeakersCount: 1,
industry: null,
deliveryTime: '1',
additionalInformation: '',
quoteCost: null
};
Finally my C# MVC Core action:
[HttpPost]
public JsonResult GetCost([FromBody]PriceRequest priceRequest)
{
var price = _priceCalculator.GetPrice(priceRequest);
return new JsonResult(price);
}
Although the object posted in is not null, none of the values have been bound:
This is the PriceRequest object:
public class PriceRequest
{
public JobDetailLevel DetailLevel { get; set; }
public int FileLengthHours { get; set; }
public int FileLengthMinutes { get; set; }
public int? ExcessiveSpeakersCount { get; set; }
public JobIndustry Industry { get; set; }
public JobDeliveryTime DeliveryTime { get; set; }
public string AdditionalInformation { get; set; }
}
Can anyone see what I am doing wrong?