This commit is contained in:
2021-01-15 20:42:21 +00:00
parent 6b8d113d3c
commit 64b6e8aa74
4 changed files with 19 additions and 7 deletions

View File

@@ -6,6 +6,7 @@ using AyaNova.Util;
using AyaNova.Api.ControllerHelpers;
using Microsoft.Extensions.Logging;
using AyaNova.Models;
using AyaNova.PickList;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using Newtonsoft.Json;
@@ -102,12 +103,20 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
//GET
//
internal async Task<PartAssembly> GetAsync(long id, bool logTheGetEvent = true)
internal async Task<PartAssembly> GetAsync(long id, bool logTheGetEvent = true, bool populatePartNames = false)
{
//.Include(w => w.Items)
var ret = await ct.PartAssembly.AsNoTracking().Include(z => z.Items).SingleOrDefaultAsync(m => m.Id == id);
if (logTheGetEvent && ret != null)
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
if (populatePartNames && ret.Items.Count > 0)
{
var partIdList = ret.Items.Select(z => z.PartId).ToList();
var PickList = PickListFactory.GetAyaPickList(AyaType.Part);
var partNames = await PickListFetcher.GetResponseAsync(PickList, null, null, true, partIdList, null, ct, log);
}
return ret;
}
@@ -127,7 +136,7 @@ namespace AyaNova.Biz
putObject.Tags = TagBiz.NormalizeTags(putObject.Tags);
putObject.CustomFields = JsonUtil.CompactJson(putObject.CustomFields);
await ValidateAsync(putObject, dbObject);
await ValidateAsync(putObject, dbObject);
if (HasErrors) return null;
ct.Replace(dbObject, putObject);
try