This commit is contained in:
2020-05-07 19:47:45 +00:00
parent 6b905baf9a
commit ef7d2d2ba2
2 changed files with 40 additions and 114 deletions

View File

@@ -61,30 +61,22 @@ namespace AyaNova.Biz
//CREATE
//Called from route and also seeder
internal async Task<Widget> CreateAsync(Widget inObj)
internal async Task<Widget> CreateAsync(Widget newObject)
{
await ValidateAsync(inObj, null);
await ValidateAsync(newObject, null);
if (HasErrors)
return null;
else
{
//do stuff with widget
Widget outObj = inObj;
//Test get serial id visible id number from generator
outObj.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
outObj.Tags = TagUtil.NormalizeTags(outObj.Tags);
outObj.CustomFields = JsonUtil.CompactJson(outObj.CustomFields);
//Save to db
await ct.Widget.AddAsync(outObj);
await ct.SaveChangesAsync();
//Handle child and associated items:
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
await SearchIndexAsync(outObj, true);
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, outObj.Tags, null);
return outObj;
{
newObject.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
newObject.Tags = TagUtil.NormalizeTags(newObject.Tags);
newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields);
await ct.Widget.AddAsync(newObject);
await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
await SearchIndexAsync(newObject, true);
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
return newObject;
}
}