This commit is contained in:
2021-03-02 00:59:37 +00:00
parent 0f2095d0cd
commit 1883246259
3 changed files with 31 additions and 12 deletions

View File

@@ -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);
}
////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -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<Unit>(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();
}
////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -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