This commit is contained in:
2020-12-09 15:40:01 +00:00
parent 8317aac35f
commit 3470d76b8b
5 changed files with 72 additions and 9 deletions

View File

@@ -13,7 +13,7 @@ namespace AyaNova.Biz
SeedTestData = 4,
BulkCoreBizObjectOperation = 5,
Backup = 6,
AttachmentMaintenance=7
AttachmentMaintenance = 7
}
@@ -28,7 +28,8 @@ namespace AyaNova.Biz
TagRemove = 3,
TagRemoveAny = 4,
TagReplace = 5,
TagReplaceAny = 6
TagReplaceAny = 6,
Delete = 7
}
}//eons

View File

@@ -154,7 +154,8 @@ namespace AyaNova.Biz
try
{
Widget dbObject = await ct.Widget.SingleOrDefaultAsync(z => z.Id == id);
if (dbObject == null){
if (dbObject == null)
{
AddError(ApiErrorCode.NOT_FOUND);
return false;
}
@@ -230,9 +231,9 @@ namespace AyaNova.Biz
//
private async Task ValidateAsync(Widget proposedObj)
{
//skip validation if seeding
if(ServerBootConfig.SEEDING) return;
//skip validation if seeding
if (ServerBootConfig.SEEDING) return;
//NOTE: In DB schema only name and serial are not nullable
//run validation and biz rules
@@ -403,7 +404,10 @@ namespace AyaNova.Biz
{
SaveIt = false;
ClearErrors();
var o = await GetAsync(id, false);
Widget o = null;
//save a fetch if it's a delete
if (job.SubType != JobSubType.Delete)
o = await GetAsync(id, false);
switch (job.SubType)
{
case JobSubType.TagAddAny:
@@ -414,6 +418,11 @@ namespace AyaNova.Biz
case JobSubType.TagReplace:
SaveIt = TagBiz.ProcessBulkTagOperation(o.Tags, (string)jobData["tag"], jobData.ContainsKey("toTag") ? (string)jobData["toTag"] : null, job.SubType);
break;
case JobSubType.Delete:
if(!await DeleteAsync(id)){
await JobsBiz.LogJobAsync(job.GId, $"Error processing item {id}: {GetErrorsAsString()}");
}
break;
default:
throw new System.ArgumentOutOfRangeException($"ProcessBulkJob -> Invalid job Subtype{job.SubType}");
}