JC6T
JC6T

Reputation: 165

ASP.NET JSONPatch returns ok status 200 but database table is not updated.

I am currently using ASP.NET MVC to create a web app. I am also using the JsonPatch library to update the database in my app.

Currently I have a situation where my method seems to get incoming data correctly and the JsonPatch HTTP response return a status 200. But my database table is not updated at all.

Below are my screenshots: enter image description here

The value to update is "BCL", is correct, but once it finishes this method, the database table is not updated at all.

The code which calls the above method is shown below: enter image description here

The http request returns a status code of 200 also. So I suppose the patch operation should be successful.

I am wonder if the version of JsonPatch that I am using makes a difference?

Thank you for the help.

Upvotes: 0

Views: 496

Answers (1)

Mohsin Mehmood
Mohsin Mehmood

Reputation: 4246

I believe you need to update the code as following:

InvPatchDocument.ApplyUpdatesTo(currentInv);
db.Update(cuurentInv);
db.SaveChanges();

Added db.Update(currentInv)

Upvotes: 1

Related Questions