This commit is contained in:
@@ -303,6 +303,7 @@ namespace AyaNova.Biz
|
||||
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
||||
foreach (Unit w in orderedList)
|
||||
{
|
||||
await PopulateVizFields(w);
|
||||
var jo = JObject.FromObject(w);
|
||||
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
|
||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||
@@ -312,12 +313,28 @@ namespace AyaNova.Biz
|
||||
return ReportData;
|
||||
}
|
||||
|
||||
//populate viz fields from provided object
|
||||
private async Task PopulateVizFields(Unit o)
|
||||
{
|
||||
o.CustomerViz = await ct.Customer.AsNoTracking().Where(x => x.Id == o.CustomerId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
if (o.UnitModelId != null)
|
||||
o.UnitModelViz = await ct.UnitModel.AsNoTracking().Where(x => x.Id == o.UnitModelId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
|
||||
if (o.ParentUnitId != null)
|
||||
o.ParentUnitViz = await ct.Unit.AsNoTracking().Where(x => x.Id == o.ParentUnitId).Select(x => x.Serial).FirstOrDefaultAsync();
|
||||
|
||||
if (o.ReplacedByUnitId != null)
|
||||
o.ReplacedByUnitViz = await ct.Unit.AsNoTracking().Where(x => x.Id == o.ReplacedByUnitId).Select(x => x.Serial).FirstOrDefaultAsync();
|
||||
|
||||
if (o.PurchasedFromVendorId != null)
|
||||
o.PurchasedFromVendorViz = await ct.Vendor.AsNoTracking().Where(x => x.Id == o.PurchasedFromVendorId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORT EXPORT
|
||||
//
|
||||
|
||||
|
||||
public async Task<JArray> GetExportData(long[] idList)
|
||||
{
|
||||
//for now just re-use the report data code
|
||||
@@ -336,7 +353,6 @@ 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();
|
||||
@@ -355,15 +371,8 @@ 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user