This commit is contained in:
2020-03-17 15:22:32 +00:00
parent 84f41e80bc
commit 6c17128f32
2 changed files with 27 additions and 20 deletions

View File

@@ -7,9 +7,7 @@
//PICKLISTS:
todo: User objects need Tags (as will all CORE objects for sure)
- Also make sure SEEDER seeds them with the same range of sample tags as for the Widgets
todo: all template routes and actual backing code and also validation, needs to validate templates
todo: clean out unneeded leftovers from AyaPickListFieldDefinition
todo: add pickers for all CORE objects (User...?)

View File

@@ -143,28 +143,28 @@ namespace AyaNova.Biz
//put
internal async Task<bool> ReplaceAsync(AyaType ayaType, string template)
{
throw new System.NotImplementedException();
// //preserve the owner ID if none was specified
// if (inObj.UserId == 0)
// inObj.UserId = dbObj.UserId;
// //Replace the db object with the PUT object
// CopyObject.Copy(inObj, dbObj, "Id");
// //Set "original" value of concurrency token to input token
// //this will allow EF to check it out
// ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = inObj.ConcurrencyToken;
// await ValidateAsync(dbObj, false);
// if (HasErrors)
// return false;
// await ct.SaveChangesAsync();
var o = await ct.PickListTemplate.FirstOrDefaultAsync(m => m.Id == (long)ayaType);
if (o == null)
{
o = new PickListTemplate();
}
o.Id = (long)ayaType;
o.Template = template;
// //Log modification and save context
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
Validate(o);
if (HasErrors)
return false;
await ct.SaveChangesAsync();
//Log modification and save context
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, o.Id, BizType, AyaEvent.Modified), ct);
//return true;
return true;
}
@@ -206,9 +206,18 @@ namespace AyaNova.Biz
//
//Can save or update?
private async Task ValidateAsync(DataListView inObj, bool isNew)
private void Validate(PickListTemplate inObj)
{
//validate that the template is valid, the type is legit etc
var TemplateType = (AyaType)inObj.Id;
if (!TemplateType.HasAttribute(typeof(CoreBizObjectAttribute)))
{
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "AyaType", "AyaType specified is not a core object type and doesn't support pick list templates");
return;
}
// //UserId required
// if (!isNew)
// {