This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user