This commit is contained in:
@@ -9,6 +9,7 @@ using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Biz;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AyaNova.Api.Controllers
|
||||
{
|
||||
@@ -50,36 +51,40 @@ namespace AyaNova.Api.Controllers
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
List<PersonalScheduleListItem> r = new List<PersonalScheduleListItem>();
|
||||
|
||||
var UserId = UserIdFromContext.Id(HttpContext.Items);
|
||||
var UType = UserTypeFromContext.Type(HttpContext.Items);
|
||||
|
||||
if (UType == UserType.Service || UType == UserType.ServiceContractor)
|
||||
{
|
||||
//trying ad-hoc join https://entityframeworkcore.com/querying-data-joining
|
||||
|
||||
var w=await ct.WorkOrderItemScheduledUser.Join(ct.WorkOrderItem,x=>x.WorkOrderItemId==)
|
||||
|
||||
var w = await ct.WorkOrder.AsSplitQuery().AsNoTracking()
|
||||
.Include(s => s.States)
|
||||
.Include(w => w.Items.OrderBy(item => item.Sequence))
|
||||
.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.OrderBy(t => t.Sequence))
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.Travels)
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.Units)
|
||||
.Include(w => w.Items)
|
||||
.ThenInclude(wi => wi.OutsideServices)
|
||||
.SingleOrDefaultAsync(z => z.Id == userId);
|
||||
// var w = await ct.WorkOrder.AsSplitQuery().AsNoTracking()
|
||||
// .Include(s => s.States)
|
||||
// .Include(w => w.Items.OrderBy(item => item.Sequence))
|
||||
// .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.OrderBy(t => t.Sequence))
|
||||
// .Include(w => w.Items)
|
||||
// .ThenInclude(wi => wi.Travels)
|
||||
// .Include(w => w.Items)
|
||||
// .ThenInclude(wi => wi.Units)
|
||||
// .Include(w => w.Items)
|
||||
// .ThenInclude(wi => wi.OutsideServices)
|
||||
// .SingleOrDefaultAsync(z => z.Id == UserId);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +106,7 @@ namespace AyaNova.Api.Controllers
|
||||
{
|
||||
public DateTime Start { get; set; }
|
||||
public DateTime End { get; set; }
|
||||
public PersonalScheduleWorkOrderColorSource ColorSource {get;set;}
|
||||
public PersonalScheduleWorkOrderColorSource ColorSource { get; set; }
|
||||
}
|
||||
|
||||
public class PersonalScheduleListItem
|
||||
@@ -110,6 +115,8 @@ namespace AyaNova.Api.Controllers
|
||||
public DateTime End { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Color { get; set; }
|
||||
public AyaType Type { get; set; }
|
||||
public long Id { get; set; }
|
||||
|
||||
}
|
||||
//------------
|
||||
|
||||
@@ -1191,6 +1191,24 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
//DASHBOARD
|
||||
await ExecQueryAsync("CREATE TABLE adashboardview (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, userid BIGINT NOT NULL UNIQUE, view TEXT NOT NULL)");
|
||||
await SetSchemaLevelAsync(++currentSchema);
|
||||
|
||||
|
||||
//SCHEDULE VIEWS
|
||||
//PERSONAL WORKORDERS
|
||||
await ExecQueryAsync("CREATE VIEW viewschedulepersonalworkorder AS SELECT "
|
||||
+ "AWORKORDERITEMSCHEDULEDUSER.ID, "
|
||||
+ "AWORKORDERITEMSCHEDULEDUSER.STARTDATE, "
|
||||
+ "AWORKORDERITEMSCHEDULEDUSER.STOPDATE, "
|
||||
+ "AWORKORDER.SERIAL, "
|
||||
+ "AWORKORDERSTATUS.COLOR AS WORKORDERSTATUSCOLOR, "
|
||||
+ "AWORKORDERITEMSTATUS.COLOR AS WORKORDERITEMSTATUSCOLOR, "
|
||||
+ "AWORKORDERITEMPRIORITY.COLOR AS WORKORDERITEMPRIORITYCOLOR "
|
||||
+ "FROM AWORKORDERITEMSCHEDULEDUSER "
|
||||
+ "LEFT JOIN AWORKORDERITEM ON AWORKORDERITEMSCHEDULEDUSER.WORKORDERITEMID = AWORKORDERITEM.ID "
|
||||
+ "LEFT JOIN AWORKORDER ON AWORKORDERITEM.WORKORDERID = AWORKORDER.ID "
|
||||
+ "LEFT JOIN AWORKORDERSTATUS ON AWORKORDER.LASTSTATUSID = AWORKORDERSTATUS.ID "
|
||||
+ "LEFT JOIN AWORKORDERITEMSTATUS ON AWORKORDERITEM.WORKORDERITEMSTATUSID = AWORKORDERITEMSTATUS.ID "
|
||||
+ "LEFT JOIN AWORKORDERITEMPRIORITY ON AWORKORDERITEM.WORKORDERITEMPRIORITYID = AWORKORDERITEMPRIORITY.ID");
|
||||
}
|
||||
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||
|
||||
Reference in New Issue
Block a user