This commit is contained in:
2020-03-17 19:38:40 +00:00
parent f10ae6829e
commit edc3d58231
2 changed files with 6 additions and 0 deletions

View File

@@ -154,6 +154,7 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// POST (replace) Pick List template /// POST (replace) Pick List template
/// (note: in this case the Id is the AyaType numerical value as there is only one template per type)
/// </summary> /// </summary>
/// <param name="template"></param> /// <param name="template"></param>
/// <returns></returns> /// <returns></returns>

View File

@@ -155,9 +155,11 @@ namespace AyaNova.Biz
internal async Task<bool> ReplaceAsync(PickListTemplate template) internal async Task<bool> ReplaceAsync(PickListTemplate template)
{ {
var o = await ct.PickListTemplate.FirstOrDefaultAsync(m => m.Id == (long)template.Id); var o = await ct.PickListTemplate.FirstOrDefaultAsync(m => m.Id == (long)template.Id);
bool bAdd = false;
if (o == null) if (o == null)
{ {
o = new PickListTemplate(); o = new PickListTemplate();
bAdd = true;
} }
o.Id = (long)template.Id; o.Id = (long)template.Id;
o.Template = template.Template; o.Template = template.Template;
@@ -166,6 +168,9 @@ namespace AyaNova.Biz
Validate(o); Validate(o);
if (HasErrors) if (HasErrors)
return false; return false;
if (bAdd)
await ct.PickListTemplate.AddAsync(o);
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log modification and save context //Log modification and save context