0👍
If I was you, I would put a breakpoint on the first line of your PostSale action and check which parts of your model are null.
The properties in your JSON are supposed to match up with your model. UserId, StatusId, DateCreated and DateSold are fine but nothing else with get passed and therefore SelectedCustomer will be null (most likely causing your problem).
{
"customerNumber": "111",
"userId": 2,
"yourReference": "Referens namn",
"dateSold": "2020-03-01T00:00:00",
"dateCreated": "2020-03-01T00:00:00",
"dateDone": "2020-03-01T00:00:00",
"dateEdited": "2020-03-01T00:00:00",
"statusId": 2,
"dateDelivered": "2020-03-01T00:00:00"
}
Should match up with below, i.e. there’
public class SaleVM
{
public enum Status
{
Started,
Ongoing,
Done,
Removed
}
public int Id { get; set; }
public string Reference { get; set; }
public DateTime DateSold { get; set; }
public DateTime DateCreated { get; set; }
public Status StatusId { get; set; }
public int UserId { get; set; }
public virtual ICollection<ArticleRow> ArticleRows { get; set; }
public virtual SelectedCustomer SelectedCustomer { get; set; }
}
Source:stackexchange.com