This commit is contained in:
2020-05-15 21:19:02 +00:00
parent 8f3118d309
commit 2b1d9353af
2 changed files with 32 additions and 27 deletions

View File

@@ -142,9 +142,9 @@ namespace AyaNova.Api.Controllers
} }
}
//------------ //------------
}//eoc }//eoc
}//eons }//eons

View File

@@ -257,10 +257,15 @@ namespace AyaNova.Biz
// //
internal static async Task<AyaTypeId> GetAncestor(AyaType ayaType, long id, AyContext ct) internal static async Task<AyaTypeId> GetAncestor(AyaType ayaType, long id, AyContext ct)
{ {
long woid = 0;
switch (ayaType) switch (ayaType)
{ {
case AyaType.WorkOrderItem: case AyaType.WorkOrderItem:
woid = await ct.WorkOrderItem.Where(z => z.Id == id).Select(z => z.WorkOrderId).SingleAsync();
break;
case AyaType.WorkOrderItemExpense: case AyaType.WorkOrderItemExpense:
woid = await ct.WorkOrderItem.Include(z => z.Expenses.Where(ex => ex.Id == id)).Select(z => z.WorkOrderId).SingleAsync();
break;
case AyaType.WorkOrderItemLabor: case AyaType.WorkOrderItemLabor:
case AyaType.WorkOrderItemLoan: case AyaType.WorkOrderItemLoan:
case AyaType.WorkOrderItemPart: case AyaType.WorkOrderItemPart:
@@ -274,32 +279,32 @@ namespace AyaNova.Biz
} }
//https://docs.microsoft.com/en-us/ef/core/querying/related-data // //https://docs.microsoft.com/en-us/ef/core/querying/related-data
//docs say this will not query twice but will recognize the duplicate woitem bit which is required for multiple grandchild collections // //docs say this will not query twice but will recognize the duplicate woitem bit which is required for multiple grandchild collections
var ret = // var ret =
await ct.WorkOrder // await ct.WorkOrder
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Expenses) // .ThenInclude(wi => wi.Expenses)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Labors) // .ThenInclude(wi => wi.Labors)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Loans) // .ThenInclude(wi => wi.Loans)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Parts) // .ThenInclude(wi => wi.Parts)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.PartRequests) // .ThenInclude(wi => wi.PartRequests)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.ScheduledUsers) // .ThenInclude(wi => wi.ScheduledUsers)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Tasks) // .ThenInclude(wi => wi.Tasks)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Travels) // .ThenInclude(wi => wi.Travels)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Units) // .ThenInclude(wi => wi.Units)
.SingleOrDefaultAsync(m => m.Id == id); // .SingleOrDefaultAsync(m => m.Id == id);
return new AyaTypeId(AyaType.WorkOrder, woid);
} }
private async Task WorkOrderSearchIndexAsync(WorkOrder obj, bool isNew) private async Task WorkOrderSearchIndexAsync(WorkOrder obj, bool isNew)