This commit is contained in:
2020-05-07 23:43:04 +00:00
parent 5ad40f976b
commit 229518b3b8

View File

@@ -300,7 +300,7 @@ namespace AyaNova.Biz
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
// GET
//
@@ -312,8 +312,8 @@ namespace AyaNova.Biz
//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.WorkOrderItem
.Include(wi => wi.WorkorderItemLabors)
await ct.WorkOrderItem
.Include(wi => wi.WorkorderItemLabors)
.Include(wi => wi.WorkorderItemParts)
.SingleOrDefaultAsync(m => m.Id == id);
if (logTheGetEvent && ret != null)
@@ -410,6 +410,23 @@ namespace AyaNova.Biz
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
// GET
//
internal async Task<WorkOrderItemLabor> GetLaborAsync(long id, bool logTheGetEvent = true)
{
//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.WorkOrderItemLabor
.SingleOrDefaultAsync(m => m.Id == id);
if (logTheGetEvent && ret != null)
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, AyaType.WorkOrderItemLabor, AyaEvent.Retrieved), ct);
return ret;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//VALIDATION
@@ -498,6 +515,24 @@ namespace AyaNova.Biz
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
// GET
//
internal async Task<WorkOrderItemPart> GetPartAsync(long id, bool logTheGetEvent = true)
{
//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.WorkOrderItemPart
.SingleOrDefaultAsync(m => m.Id == id);
if (logTheGetEvent && ret != null)
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, AyaType.WorkOrderItemPart, AyaEvent.Retrieved), ct);
return ret;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//VALIDATION