From 1883246259cfba159106e902e3c3ce6ceda386cd Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 2 Mar 2021 00:59:37 +0000 Subject: [PATCH] --- server/AyaNova/biz/PartBiz.cs | 2 +- server/AyaNova/biz/UnitBiz.cs | 11 ++++++++++- server/AyaNova/models/Unit.cs | 30 ++++++++++++++++++++---------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/server/AyaNova/biz/PartBiz.cs b/server/AyaNova/biz/PartBiz.cs index 802cfc35..cb78bbb4 100644 --- a/server/AyaNova/biz/PartBiz.cs +++ b/server/AyaNova/biz/PartBiz.cs @@ -28,7 +28,7 @@ namespace AyaNova.Biz if (httpContext != null) return new PartBiz(ct, UserIdFromContext.Id(httpContext.Items), UserTranslationIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items)); else - return new PartBiz(ct, 1, translationId, AuthorizationRoles.BizAdminFull); + return new PartBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdminFull); } //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/server/AyaNova/biz/UnitBiz.cs b/server/AyaNova/biz/UnitBiz.cs index fc3850a9..62ef4e2f 100644 --- a/server/AyaNova/biz/UnitBiz.cs +++ b/server/AyaNova/biz/UnitBiz.cs @@ -336,6 +336,7 @@ namespace AyaNova.Biz var jsset = JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = new AyaNova.Util.JsonUtil.ShouldSerializeContractResolver(new string[] { "Concurrency", "Id", "CustomFields" }) }); foreach (JObject j in ja) { + await PopulateVizFields(w); var w = j.ToObject(jsset); if (j["CustomFields"] != null) w.CustomFields = j["CustomFields"].ToString(); @@ -354,7 +355,15 @@ namespace AyaNova.Biz return ImportResult; } - +rolling through ayatypes from top to bottom and Unit is where I left off + //populate viz fields from provided object + private async Task PopulateVizFields(Unit o) + { + if (o.HeadOfficeId != null) + o.HeadOfficeViz = await ct.HeadOffice.AsNoTracking().Where(x=>x.Id==o.HeadOfficeId).Select(x => x.Name).FirstOrDefaultAsync(); + if (o.ContractId != null) + o.ContractViz = await ct.Contract.AsNoTracking().Where(x=>x.Id==o.ContractId).Select(x => x.Name).FirstOrDefaultAsync(); + } //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/server/AyaNova/models/Unit.cs b/server/AyaNova/models/Unit.cs index 82e43137..67778dbf 100644 --- a/server/AyaNova/models/Unit.cs +++ b/server/AyaNova/models/Unit.cs @@ -25,15 +25,25 @@ namespace AyaNova.Models public string Serial { get; set; } [Required] public long CustomerId { get; set; } + [NotMapped] + public string CustomerViz { get; set; } public long? ParentUnitId { get; set; } + [NotMapped] + public string ParentUnitViz { get; set; } public long? UnitModelId { get; set; } + [NotMapped] + public string UnitModelViz { get; set; } public bool UnitHasOwnAddress { get; set; } public bool BoughtHere { get; set; } public long? PurchasedFromVendorId { get; set; } + [NotMapped] + public string PurchasedFromVendorViz { get; set; } public string Receipt { get; set; } public DateTime? PurchasedDate { get; set; } public string Description { get; set; } public long? ReplacedByUnitId { get; set; } + [NotMapped] + public string ReplacedByUnitViz { get; set; } public bool OverrideModelWarranty { get; set; } public int? WarrantyLength { get; set; } public string WarrantyTerms { get; set; } @@ -45,7 +55,7 @@ namespace AyaNova.Models public string Text3 { get; set; } public string Text4 { get; set; } - //PHYSICAL ADDRESS + //PHYSICAL ADDRESS public string Address { get; set; } public string City { get; set; } public string Region { get; set; } @@ -61,17 +71,17 @@ namespace AyaNova.Models [NotMapped, JsonIgnore] public AyaType AyaType { get => AyaType.Unit; } - //convenience links - [JsonIgnore] - public Customer Customer { get; set; } - [JsonIgnore] - public UnitModel UnitModel { get; set; } + // //convenience links // [JsonIgnore] - // public Unit ParentUnit { get; set; } - [JsonIgnore] - public Vendor PurchasedFromVendor { get; set; } + // public Customer Customer { get; set; } // [JsonIgnore] - // public Unit ReplacedByUnit { get; set; } + // public UnitModel UnitModel { get; set; } + // // [JsonIgnore] + // // public Unit ParentUnit { get; set; } + // [JsonIgnore] + // public Vendor PurchasedFromVendor { get; set; } + // // [JsonIgnore] + // // public Unit ReplacedByUnit { get; set; } }//eoc