PATCH when working with DTO

Now I saw that using autoMapper I can do just

CreateMap<JsonPatchDocument<AccountDTO>, JsonPatchDocument<Account>>();
        CreateMap<Operation<AccountDTO>, Operation<Account>>();

and it work like a charm :)


Eventually,

I just remove the type from JsonPatchDocument, and saw that it can work without type...

[HttpPatch("{id}")]
    public AccountDTO Patch(int id, [FromBody]JsonPatchDocument patch)
    {
        return _mapper.Map<AccountDTO>(_accountBlService.EditAccount(id, patch));
    }

And then, In BL layer,

public Account EditAccount(int id, JsonPatchDocument patch)
    {
        var account = _context.Accounts.Single(a => a.AccountId == id);
        var uneditablePaths = new List<string> { "/accountId" };

        if (patch.Operations.Any(operation => uneditablePaths.Contains(operation.path)))
        {
            throw new UnauthorizedAccessException();
        }
        patch.ApplyTo(account);            
        return account;
    }