This commit is contained in:
2020-05-15 20:53:44 +00:00
parent 87437f60de
commit 7806e0df26
3 changed files with 61 additions and 13 deletions

View File

@@ -252,6 +252,41 @@ namespace AyaNova.Biz
}
////////////////////////////////////////////////////////////////////////////////////////////////
// GET ANCESTOR
//
internal static async Task<AyaTypeId> GetAncestor(AyaType ayType, long id, AyContext ct)
{
//Note: there could be rules checking here in future, i.e. can only get own workorder or something
//if so, then need to implement AddError and in route handle Null return with Error check just like PUT route does now
//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
var ret =
await ct.WorkOrder
.Include(w => w.Items)
.ThenInclude(wi => wi.Expenses)
.Include(w => w.Items)
.ThenInclude(wi => wi.Labors)
.Include(w => w.Items)
.ThenInclude(wi => wi.Loans)
.Include(w => w.Items)
.ThenInclude(wi => wi.Parts)
.Include(w => w.Items)
.ThenInclude(wi => wi.PartRequests)
.Include(w => w.Items)
.ThenInclude(wi => wi.ScheduledUsers)
.Include(w => w.Items)
.ThenInclude(wi => wi.Tasks)
.Include(w => w.Items)
.ThenInclude(wi => wi.Travels)
.Include(w => w.Items)
.ThenInclude(wi => wi.Units)
.SingleOrDefaultAsync(m => m.Id == id);
}
private async Task WorkOrderSearchIndexAsync(WorkOrder obj, bool isNew)
{