This commit is contained in:
2021-09-14 19:54:57 +00:00
parent 8a1c01b2e1
commit f5d22b8a46
2 changed files with 49 additions and 24 deletions

View File

@@ -9,6 +9,7 @@ using AyaNova.Api.ControllerHelpers;
using AyaNova.Biz; using AyaNova.Biz;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.Linq; using System.Linq;
using System.Collections.Generic;
namespace AyaNova.Api.Controllers namespace AyaNova.Api.Controllers
{ {
@@ -50,36 +51,40 @@ namespace AyaNova.Api.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
List<PersonalScheduleListItem> r = new List<PersonalScheduleListItem>();
var UserId = UserIdFromContext.Id(HttpContext.Items); var UserId = UserIdFromContext.Id(HttpContext.Items);
var UType = UserTypeFromContext.Type(HttpContext.Items); var UType = UserTypeFromContext.Type(HttpContext.Items);
if (UType == UserType.Service || UType == UserType.ServiceContractor) 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() // var w = await ct.WorkOrder.AsSplitQuery().AsNoTracking()
.Include(s => s.States) // .Include(s => s.States)
.Include(w => w.Items.OrderBy(item => item.Sequence)) // .Include(w => w.Items.OrderBy(item => item.Sequence))
.ThenInclude(wi => wi.Expenses) // .ThenInclude(wi => wi.Expenses)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Labors) // .ThenInclude(wi => wi.Labors)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Loans) // .ThenInclude(wi => wi.Loans)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Parts) // .ThenInclude(wi => wi.Parts)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.PartRequests) // .ThenInclude(wi => wi.PartRequests)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.ScheduledUsers) // .ThenInclude(wi => wi.ScheduledUsers)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Tasks.OrderBy(t => t.Sequence)) // .ThenInclude(wi => wi.Tasks.OrderBy(t => t.Sequence))
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Travels) // .ThenInclude(wi => wi.Travels)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.Units) // .ThenInclude(wi => wi.Units)
.Include(w => w.Items) // .Include(w => w.Items)
.ThenInclude(wi => wi.OutsideServices) // .ThenInclude(wi => wi.OutsideServices)
.SingleOrDefaultAsync(z => z.Id == userId); // .SingleOrDefaultAsync(z => z.Id == UserId);
} }
@@ -101,7 +106,7 @@ namespace AyaNova.Api.Controllers
{ {
public DateTime Start { get; set; } public DateTime Start { get; set; }
public DateTime End { get; set; } public DateTime End { get; set; }
public PersonalScheduleWorkOrderColorSource ColorSource {get;set;} public PersonalScheduleWorkOrderColorSource ColorSource { get; set; }
} }
public class PersonalScheduleListItem public class PersonalScheduleListItem
@@ -110,6 +115,8 @@ namespace AyaNova.Api.Controllers
public DateTime End { get; set; } public DateTime End { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Color { get; set; } public string Color { get; set; }
public AyaType Type { get; set; }
public long Id { get; set; }
} }
//------------ //------------

View File

@@ -1191,6 +1191,24 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
//DASHBOARD //DASHBOARD
await ExecQueryAsync("CREATE TABLE adashboardview (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, userid BIGINT NOT NULL UNIQUE, view TEXT NOT NULL)"); 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); 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!!!! //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!