This commit is contained in:
2018-09-06 15:39:37 +00:00
parent 7ecd9eda9d
commit 1382d6c7ce
3 changed files with 10 additions and 10 deletions

View File

@@ -169,6 +169,9 @@ namespace AyaNova.Biz
//patch
internal bool Patch(Tag dbObj, JsonPatchDocument<Tag> objectPatch, uint concurrencyToken)
{
//Validate Patch is allowed
if (!ValidateJsonPatch<Tag>.Validate(this, objectPatch)) return false;
//Do the patching
objectPatch.ApplyTo(dbObj);
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;

View File

@@ -64,22 +64,16 @@ namespace AyaNova.Biz
//patch
internal bool Patch(UserOptions dbObj, JsonPatchDocument<UserOptions> objectPatch, uint concurrencyToken)
{
//check for in-valid patches
if(objectPatch.Operations.Any(m=>m.path=="Id"))
{
AddError(ValidationErrorType.InvalidOperation,"Id");
return false;
}
//Validate Patch is allowed
if (!ValidateJsonPatch<UserOptions>.Validate(this, objectPatch)) return false;
//Do the patching
objectPatch.ApplyTo(dbObj);
objectPatch.ApplyTo(dbObj);
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
Validate(dbObj);
if (HasErrors)
return false;
return true;
}

View File

@@ -154,6 +154,9 @@ namespace AyaNova.Biz
//patch
internal bool Patch(Widget dbObj, JsonPatchDocument<Widget> objectPatch, uint concurrencyToken)
{
//Validate Patch is allowed
if (!ValidateJsonPatch<Widget>.Validate(this, objectPatch)) return false;
//Do the patching
objectPatch.ApplyTo(dbObj);
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;