This commit is contained in:
@@ -40,40 +40,7 @@ namespace AyaNova.Biz
|
||||
return await ct.WorkOrder.AnyAsync(e => e.Id == id);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// GET
|
||||
///
|
||||
///
|
||||
|
||||
internal async Task<WorkOrder> GetAsync(long fetchId, bool logTheGetEvent = true)
|
||||
{
|
||||
/*
|
||||
https://docs.microsoft.com/en-us/ef/core/querying/related-data
|
||||
using (var context = new BloggingContext())
|
||||
{
|
||||
var blogs = context.Blogs
|
||||
.Include(blog => blog.Posts)
|
||||
.ThenInclude(post => post.Author)
|
||||
.ThenInclude(author => author.Photo)
|
||||
.ToList();
|
||||
}
|
||||
WARNING: Since version 3.0.0, each Include will cause an additional JOIN to be added to SQL queries produced by relational providers, whereas previous versions generated additional SQL queries. This can significantly change the performance of your queries, for better or worse. In particular, LINQ queries with an exceedingly high number of Include operators may need to be broken down into multiple separate LINQ queries in order to avoid the cartesian explosion problem.
|
||||
*/
|
||||
//This is simple so nothing more here, but often will be copying to a different output object or some other ops
|
||||
//var ret = await ct.WorkOrder.SingleOrDefaultAsync(m => m.Id == fetchId);
|
||||
|
||||
var ret = await ct.WorkOrder.Include(w => w.WorkorderItems).SingleOrDefaultAsync(m => m.Id == fetchId);
|
||||
|
||||
if (logTheGetEvent && ret != null)
|
||||
{
|
||||
//Log
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, fetchId, BizType, AyaEvent.Retrieved), ct);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//CREATE
|
||||
|
||||
//TODO: Modify this to expect a workorder object like most POST routes for other objects
|
||||
@@ -81,15 +48,15 @@ WARNING: Since version 3.0.0, each Include will cause an additional JOIN to be a
|
||||
|
||||
|
||||
//Called from route and also seeder
|
||||
internal async Task<WorkOrder> CreateAsync(WorkOrder inObj)
|
||||
internal async Task<WorkOrder> CreateAsync(WorkOrder newObject)
|
||||
{
|
||||
await ValidateAsync(inObj, null);
|
||||
await ValidateAsync(newObject, null);
|
||||
if (HasErrors)
|
||||
return null;
|
||||
else
|
||||
{
|
||||
//do stuff with widget
|
||||
WorkOrder outObj = inObj;
|
||||
WorkOrder outObj = newObject;
|
||||
|
||||
//Test get serial id visible id number from generator
|
||||
outObj.Serial = ServerBootConfig.WORKORDER_SERIAL.GetNext();
|
||||
@@ -186,6 +153,42 @@ WARNING: Since version 3.0.0, each Include will cause an additional JOIN to be a
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// GET
|
||||
///
|
||||
///
|
||||
|
||||
internal async Task<WorkOrder> GetAsync(long fetchId, bool logTheGetEvent = true)
|
||||
{
|
||||
/*
|
||||
https://docs.microsoft.com/en-us/ef/core/querying/related-data
|
||||
using (var context = new BloggingContext())
|
||||
{
|
||||
var blogs = context.Blogs
|
||||
.Include(blog => blog.Posts)
|
||||
.ThenInclude(post => post.Author)
|
||||
.ThenInclude(author => author.Photo)
|
||||
.ToList();
|
||||
}
|
||||
WARNING: Since version 3.0.0, each Include will cause an additional JOIN to be added to SQL queries produced by relational providers, whereas previous versions generated additional SQL queries. This can significantly change the performance of your queries, for better or worse. In particular, LINQ queries with an exceedingly high number of Include operators may need to be broken down into multiple separate LINQ queries in order to avoid the cartesian explosion problem.
|
||||
*/
|
||||
//This is simple so nothing more here, but often will be copying to a different output object or some other ops
|
||||
//var ret = await ct.WorkOrder.SingleOrDefaultAsync(m => m.Id == fetchId);
|
||||
|
||||
var ret = await ct.WorkOrder.Include(w => w.WorkorderItems).SingleOrDefaultAsync(m => m.Id == fetchId);
|
||||
|
||||
if (logTheGetEvent && ret != null)
|
||||
{
|
||||
//Log
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, fetchId, BizType, AyaEvent.Retrieved), ct);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//UPDATE
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user