I have a fairly complex CRM page that allows a user to schedule a class (like, where people actually attend and learn). The creation is done via a Modal that allows them to fill out some fields and press the Save button. That submission gathers the data entered into an object, and passes it to C#.
Or at least that's the goal. I've done it hundreds of times on other pages, with no problem, but in this instance I'm getting the "No parameterless constructor defined for this object" error. The thing is, it shouldn't BE parameterless - I'm passing params to it.
The AngularJS (1.7.5):
scAPI.DoTheThing({
classId : vm.item.Class.ClassId,
venueId : vm.item.Class.VenueId,
courseDate : vm.item.Class.CourseDate,
startTime : vm.item.Class.StartTime,
cost : vm.item.Class.Cost,
complianceComment: vm.item.Class.ComplianceComment,
isPrivate : hasValue(vm.item.Class.Private) ? vm.item.Class.Private : false,
instructors : vm.item.Instructors
})
.then(
function(result) {
var bob = 1;
}
)
.catch(function(errorOne) {
handleApiCallError(errorOne,
function() {
vm.readOnly = false;
vm.classSaving = false;
});
});
All of the parameters have values... "scAPI.DoTheThing" fires off this call:
DoTheThing: function (params, error) {
return $http
.post("/SchoolManagement/NewScheduledClass", params)
.then(handleNGV4Success)
.catch(function (e) {
handleNGV4Error(e, error);
});
}
which in turn should be hitting this C# method:
public ActionResult NewScheduledClass(int classId, int venueId, string courseDate, string startTime, decimal cost, string complianceComment, bool isPrivate,
IEnumerable<InstructorDataWithRoles> instructors)
{
var cDate = parseDate(courseDate);
var sTime = parseDate(startTime);
var newClass = _smap.NewScheduledClass(classId, venueId, cDate, sTime, cost, complianceComment, isPrivate, instructors);
var result = new
{
newClass
};
return HandleRequest(() => result);
}
Like I said, I've made this same kind of method call hundreds of times in this app, with no issues, but in this instance I'm having problems. The only thing I'm doing different in this C# controller.cs is that the Controller is a partial class. This particular controller handles 5 tabs worth of functionality in the UI, and I figured it would be best to put each tabs back end code into separate class files (ease of maintenance). This was the first-of-its-type in our solution, and all the other tabs are working fine, but this one is just screwed up for some reason.
InstructorDataWithRoleshave a parameterless constructor? The default model binder requires a parameterless constructor for all object being bound.