My current implementation has two http.PatchAsync() calls to the Web API, i.e. to multiple controller action methods, one for each Entity.
Thought that I could improve on this by sending one DTO containing the data the needs to be updated for multiple Entities, only one packet at risk of loss vs. multiple.
Now I have hit a road block as I cannot find how to use the same JsonPatchDocument for several Entities
Code so far:
[Route("UpdatePartial/{id}")] /
[HttpPatch]
public async Task<IActionResult> Patch(int id, bool hasQbWc, [FromBody] JsonPatchDocument<TxnBillingPatch> txnPatch)
{
if (txnPatch == null) { return BadRequest(); }
var theTxn = context.Transactions.FirstOrDefault(t => t.TransactionId == id);
if (theTxn == null) { return NotFound(); }
**txnPatch.ApplyTo(theTxn, ModelState);**
var isValid = TryValidateModel(theTxn);
if (!isValid) { return BadRequest(ModelState); }
//await context.SaveChangesAsync();
return NoContent();
}
Squiggles on the bolded line with "cannot convert from Transaction (the Entity) to TxnBillingPatch (the DTO)