From 64b6e8aa74909ab302ae90b074b1a789cc626e0c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 15 Jan 2021 20:42:21 +0000 Subject: [PATCH] --- server/AyaNova/PickList/PickListFetcher.cs | 3 +++ server/AyaNova/biz/AyaFormFieldDefinitions.cs | 2 +- server/AyaNova/biz/PartAssemblyBiz.cs | 15 ++++++++++++--- server/AyaNova/models/PartAssemblyItem.cs | 6 +++--- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/server/AyaNova/PickList/PickListFetcher.cs b/server/AyaNova/PickList/PickListFetcher.cs index 3921c981..fb237e90 100644 --- a/server/AyaNova/PickList/PickListFetcher.cs +++ b/server/AyaNova/PickList/PickListFetcher.cs @@ -13,6 +13,9 @@ namespace AyaNova.PickList internal static async Task> GetResponseAsync(IAyaPickList PickList, string autoCompleteQuery, string tagSpecificQuery, bool includeInactive, long[] preIds, string variant, AyContext ct, ILogger log) { + //This may be called internally in *Biz classes who don't have a log of their own + if (log == null) + log = AyaNova.Util.ApplicationLogging.CreateLogger("PickListFetcher"); //Sort out effective Template string Template = null; diff --git a/server/AyaNova/biz/AyaFormFieldDefinitions.cs b/server/AyaNova/biz/AyaFormFieldDefinitions.cs index 01aad9f3..b9846330 100644 --- a/server/AyaNova/biz/AyaFormFieldDefinitions.cs +++ b/server/AyaNova/biz/AyaFormFieldDefinitions.cs @@ -488,7 +488,7 @@ namespace AyaNova.Biz { List l = new List(); - l.Add(new AyaFormFieldDefinition { TKey = "Name", FieldKey = "Name", Hideable = false }); + l.Add(new AyaFormFieldDefinition { TKey = "PartAssemblyName", FieldKey = "Name", Hideable = false }); l.Add(new AyaFormFieldDefinition { TKey = "PartAssemblyNotes", FieldKey = "Notes" }); l.Add(new AyaFormFieldDefinition { TKey = "Active", FieldKey = "Active", Hideable = false }); l.Add(new AyaFormFieldDefinition { TKey = "Tags", FieldKey = "Tags" }); diff --git a/server/AyaNova/biz/PartAssemblyBiz.cs b/server/AyaNova/biz/PartAssemblyBiz.cs index 0b6ce081..67244b2a 100644 --- a/server/AyaNova/biz/PartAssemblyBiz.cs +++ b/server/AyaNova/biz/PartAssemblyBiz.cs @@ -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 GetAsync(long id, bool logTheGetEvent = true) + internal async Task 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 diff --git a/server/AyaNova/models/PartAssemblyItem.cs b/server/AyaNova/models/PartAssemblyItem.cs index 6d23a707..65194880 100644 --- a/server/AyaNova/models/PartAssemblyItem.cs +++ b/server/AyaNova/models/PartAssemblyItem.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using AyaNova.Biz; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; @@ -19,6 +16,9 @@ namespace AyaNova.Models [JsonIgnore] public PartAssembly PartAssembly { get; set; } + [NotMapped] + public string PartDisplay {get;set;} + }//eoc }//eons \ No newline at end of file