I am encountering an issue when trying to send a complex object to my SignalR hub. The JavaScript object I'm sending matches perfectly with my C# object, so theoretically everything should be functioning correctly. However, for some reason, my UpdateEmployee
method is not being triggered. It's puzzling since other methods in my hub are working fine with simple types. Here is my current setup -
SignalR Hub
public void UpdateEmployee(int userId, Employee employee)
{
// Update employee
}
The Employee
model is defined as follows:
public class Employee: Persistable
{
[DataMember]
public DateTime? DateOfBirth { get; set; }
[DataMember]
public string FirstName { get; set; }
[DataMember]
public string LastName { get; set; }
}
It simply inherits from the Persistable
class:
[DataContract]
public class Persistable
{
[DataMember(Name = "id")]
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
}
I am attempting to call the method from my SignalR JavaScript client like this:
$.connection.myHub.server.updateEmployee(userId, employee);
The structure of my employee
object in JavaScript is as follows:
{ Id: 1, FirstName: "Test", LastName: "One", DateOfBirth: "01012001" }
Can you see anything incorrect in my implementation?