diff --git a/Brizco.Api/AppSettings/appsettings.Development.json b/Brizco.Api/AppSettings/appsettings.Development.json
index 79b9a74..01d19fb 100644
--- a/Brizco.Api/AppSettings/appsettings.Development.json
+++ b/Brizco.Api/AppSettings/appsettings.Development.json
@@ -13,7 +13,7 @@
}
},
"SiteSettings": {
- "BaseUrl": "http://192.168.88.12:32769",
+ "BaseUrl": "http://192.168.88.251:32769",
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
"UserSetting": {
"Username": "root",
diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj
index ad4ed84..dc03ef0 100644
--- a/Brizco.Api/Brizco.Api.csproj
+++ b/Brizco.Api/Brizco.Api.csproj
@@ -11,47 +11,47 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/Brizco.Api/Controllers/ReportController.cs b/Brizco.Api/Controllers/ReportController.cs
new file mode 100644
index 0000000..bc3378f
--- /dev/null
+++ b/Brizco.Api/Controllers/ReportController.cs
@@ -0,0 +1,35 @@
+using Brizco.Core.CoreServices.ReportServices.Commands;
+using MediatR;
+
+namespace Brizco.Api.Controllers;
+
+public class ReportController : ICarterModule
+{
+ public void AddRoutes(IEndpointRouteBuilder app)
+ {
+ var group = app.NewVersionedApi("Report")
+ .MapGroup("api/report");
+
+ group.MapGet("task", GetTasksReportAsync)
+ .WithDisplayName("Get Tasks Report")
+ .HasApiVersion(1.0);
+
+ group.MapGet("shit/plan/{shiftPLanId}", GetShiftPlanReportAsync)
+ .WithDisplayName("Get ShiftPlan Report")
+ .HasApiVersion(1.0);
+ }
+
+ public async Task GetTasksReportAsync([FromServices]IMediator mediator,CancellationToken cancellationToken)
+ {
+ var file = await mediator.Send(new TaskReportCommand(),cancellationToken);
+ string fileName = $"TaskReport_{DateTime.Now:yyyy-MM-dd}.xlsx";
+ return TypedResults.File(file, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
+ }
+
+ public async Task GetShiftPlanReportAsync(Guid shiftPLanId,[FromServices] IMediator mediator, CancellationToken cancellationToken)
+ {
+ var file = await mediator.Send(new ShiftPlanReportCommand(ShiftPlanId: shiftPLanId), cancellationToken);
+ string fileName = $"ShiftPlanReport_{DateTime.Now:yyyy-MM-dd}.xlsx";
+ return TypedResults.File(file, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Common/Brizco.Common.csproj b/Brizco.Common/Brizco.Common.csproj
index ce92ab5..2bff86c 100644
--- a/Brizco.Common/Brizco.Common.csproj
+++ b/Brizco.Common/Brizco.Common.csproj
@@ -11,7 +11,7 @@
-
+
-->
diff --git a/Brizco.Common/Models/Claims/ApplicationClaims.cs b/Brizco.Common/Models/Claims/ApplicationClaims.cs
index 38fbf63..b86f6d0 100644
--- a/Brizco.Common/Models/Claims/ApplicationClaims.cs
+++ b/Brizco.Common/Models/Claims/ApplicationClaims.cs
@@ -245,6 +245,27 @@ public static class ApplicationClaims
ViewComplexSettings.GetClaim
};
+ public static List ViewerOwnerClaims = new List
+ {
+ ViewStaffs.GetClaim,
+
+ ViewActivities.GetClaim,
+
+ ViewTasks.GetClaim,
+
+ ViewShiftPlans.GetClaim,
+
+ ViewShifts.GetClaim,
+
+ ViewRoutines.GetClaim,
+
+ ViewPositions.GetClaim,
+
+ ViewSections.GetClaim,
+
+ ViewDashboard.GetClaim,
+ ViewComplexSettings.GetClaim
+ };
public static List SuperVisorClaims = new List
{
diff --git a/Brizco.Core/Brizco.Core.csproj b/Brizco.Core/Brizco.Core.csproj
index 08069b0..cf1d8fa 100644
--- a/Brizco.Core/Brizco.Core.csproj
+++ b/Brizco.Core/Brizco.Core.csproj
@@ -12,7 +12,8 @@
-
+
+
@@ -32,8 +33,10 @@
+
+
@@ -41,12 +44,16 @@
+
+
+
+
diff --git a/Brizco.Core/CoreServices/ReportServices/Commands/IReportService.cs b/Brizco.Core/CoreServices/ReportServices/Commands/IReportService.cs
new file mode 100644
index 0000000..a88f48e
--- /dev/null
+++ b/Brizco.Core/CoreServices/ReportServices/Commands/IReportService.cs
@@ -0,0 +1,6 @@
+namespace Brizco.Core.CoreServices.ReportServices.Commands;
+
+public interface IReportService : IScopedDependency
+{
+ Task GetTaskReportAsync();
+}
\ No newline at end of file
diff --git a/Brizco.Core/CoreServices/ReportServices/Commands/ReportCommands.cs b/Brizco.Core/CoreServices/ReportServices/Commands/ReportCommands.cs
new file mode 100644
index 0000000..9334ed9
--- /dev/null
+++ b/Brizco.Core/CoreServices/ReportServices/Commands/ReportCommands.cs
@@ -0,0 +1,4 @@
+namespace Brizco.Core.CoreServices.ReportServices.Commands;
+
+public sealed record TaskReportCommand() : IRequest;
+public sealed record ShiftPlanReportCommand(Guid ShiftPlanId) : IRequest;
\ No newline at end of file
diff --git a/Brizco.Core/CoreServices/ReportServices/ShiftPlanReportCommandHandler.cs b/Brizco.Core/CoreServices/ReportServices/ShiftPlanReportCommandHandler.cs
new file mode 100644
index 0000000..b01f036
--- /dev/null
+++ b/Brizco.Core/CoreServices/ReportServices/ShiftPlanReportCommandHandler.cs
@@ -0,0 +1,126 @@
+using Brizco.Domain.Entities.Shift;
+using Brizco.Domain.Entities.Task;
+
+namespace Brizco.Core.CoreServices.ReportServices;
+public class ShiftPlanReportCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+
+ public ShiftPlanReportCommandHandler(IRepositoryWrapper repositoryWrapper)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ }
+ public async Task Handle(ShiftPlanReportCommand request, CancellationToken cancellationToken)
+ {
+ var shiftPlan = await _repositoryWrapper.SetRepository()
+ .TableNoTracking
+ .Where(sp => sp.Id == request.ShiftPlanId)
+ .Select(ShiftPlanMapper.ProjectToSDto)
+ .FirstOrDefaultAsync(cancellationToken);
+ if (shiftPlan == null)
+ throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound);
+ var activities = await _repositoryWrapper.SetRepository()
+ .TableNoTracking
+ .Where(sp => sp.ShiftId == shiftPlan.ShiftId && sp.SetFor.Date == shiftPlan.PlanFor.Date)
+ .Select(ActivityMapper.ProjectToSDto)
+ .ToListAsync(cancellationToken);
+
+
+ var workbook = new XSSFWorkbook();
+ var sheet = workbook.CreateSheet($"شیفت {shiftPlan.ShiftTitle} - {shiftPlan.PlanFor.ToPersianDateTime().ToLongDateString()}");
+ sheet.IsRightToLeft = true;
+ int selectedRow = 1;
+ CreateHeader(sheet, workbook);
+ foreach (var activity in activities)
+ {
+ var row = sheet.GetRow(selectedRow) ?? sheet.CreateRow(selectedRow);
+ row.Height = 700;
+
+ var style = workbook.CreateCellStyle();
+
+ style.VerticalAlignment = VerticalAlignment.Center;
+ style.Alignment = HorizontalAlignment.Center;
+ style.WrapText = true;
+
+ var cell = row.CreateCell(0);
+ cell.CellStyle = style;
+ cell.SetCellValue(activity.Title);
+
+ var personCell = row.CreateCell(1);
+ personCell.CellStyle = style;
+ personCell.SetCellValue(activity.UserFullName);
+
+ var statusCell = row.CreateCell(2);
+ statusCell.CellStyle = style;
+ statusCell.SetCellValue(activity.Status.ToDisplay());
+
+ var doneAtCell = row.CreateCell(3);
+ doneAtCell.CellStyle = style;
+ doneAtCell.SetCellValue(activity.Title);
+
+ var unDoneReasonCell = row.CreateCell(4);
+ unDoneReasonCell.CellStyle = style;
+ unDoneReasonCell.SetCellValue(activity.UnDoneReason);
+
+ selectedRow++;
+ }
+
+ sheet.SetColumnWidth(0, 25600);
+ sheet.SetColumnWidth(1, 7000);
+ sheet.SetColumnWidth(2, 7000);
+ sheet.SetColumnWidth(3, 7000);
+ sheet.SetColumnWidth(4, 7000);
+
+
+ var stream = new MemoryStream();
+ workbook.Write(stream);
+ var content = stream.ToArray();
+
+ return content;
+ }
+
+ void CreateHeader(ISheet sheet, XSSFWorkbook workbook)
+ {
+ var headerRow = sheet.GetRow(0) ?? sheet.CreateRow(0);
+ headerRow.Height = 700;
+
+ var font = workbook.CreateFont();
+ font.IsBold = true;
+ font.Color = NPOI.HSSF.Util.HSSFColor.White.Index;
+
+ //font.FontHeight = 16;
+ var style = workbook.CreateCellStyle();
+ style.Alignment = HorizontalAlignment.Center;
+ style.VerticalAlignment = VerticalAlignment.Center;
+ style.WrapText = true;
+ style.SetFont(font);
+
+ byte[] rgb = new byte[3] { 30, 81, 123 };
+ XSSFColor color = new XSSFColor(rgb);
+ //style.SetFillBackgroundColor(color);
+ //style.SetFillForegroundColor(color);
+
+ style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.BlueGrey.Index;
+ style.FillPattern = FillPattern.SolidForeground;
+
+ var shiftNameHeaderCell = headerRow.CreateCell(0);
+ shiftNameHeaderCell.CellStyle = style;
+ shiftNameHeaderCell.SetCellValue("تسکــــ");
+
+ var taskNameHeaderCell = headerRow.CreateCell(1);
+ taskNameHeaderCell.CellStyle = style;
+ taskNameHeaderCell.SetCellValue("شخص");
+
+ var positionNameHeaderCell = headerRow.CreateCell(2);
+ positionNameHeaderCell.CellStyle = style;
+ positionNameHeaderCell.SetCellValue("وضعیت");
+
+ var doneAtHeaderCell = headerRow.CreateCell(3);
+ doneAtHeaderCell.CellStyle = style;
+ doneAtHeaderCell.SetCellValue("انجام شده در");
+
+ var unDoneReasonAtHeaderCell = headerRow.CreateCell(4);
+ unDoneReasonAtHeaderCell.CellStyle = style;
+ unDoneReasonAtHeaderCell.SetCellValue("دلیل انجام نشدن");
+ }
+}
diff --git a/Brizco.Core/CoreServices/ReportServices/TaskReportCommandHandler.cs b/Brizco.Core/CoreServices/ReportServices/TaskReportCommandHandler.cs
new file mode 100644
index 0000000..72ecd66
--- /dev/null
+++ b/Brizco.Core/CoreServices/ReportServices/TaskReportCommandHandler.cs
@@ -0,0 +1,213 @@
+using Brizco.Domain.Entities.Task;
+using Task = System.Threading.Tasks.Task;
+
+namespace Brizco.Core.CoreServices.ReportServices;
+public class TaskReportCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+
+ public TaskReportCommandHandler(IRepositoryWrapper repositoryWrapper)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ }
+ public async Task Handle(TaskReportCommand request, CancellationToken cancellationToken)
+ {
+ var tasks = await _repositoryWrapper.SetRepository()
+ .TableNoTracking
+ .Select(TaskMapper.ProjectToLDto)
+ .ToListAsync(cancellationToken);
+
+ var workbook = new XSSFWorkbook();
+
+ var sheet = workbook.CreateSheet("روزانه");
+
+ sheet.IsRightToLeft = true;
+ int selectedRow = 1;
+ var originalTasks = tasks.Where(t => t.ScheduleType == TaskScheduleType.Daily).ToList();
+
+ CreateHeader(sheet, workbook);
+
+ var shiftsTask = originalTasks.SelectMany(dt => dt.Shifts).ToList();
+ foreach (var taskShiftGrouped in shiftsTask.GroupBy(t => t.ShiftId))
+ {
+ var count = taskShiftGrouped.ToList().Count - 1;
+ var shiftName = taskShiftGrouped.FirstOrDefault()?.ShiftName ?? string.Empty;
+ CreateShiftName(selectedRow, selectedRow + count, shiftName, sheet, workbook);
+ int j = selectedRow;
+ foreach (var taskShiftSDto in taskShiftGrouped)
+ {
+ var row = sheet.GetRow(j) ?? sheet.CreateRow(j);
+ row.Height = 700;
+
+ var style = workbook.CreateCellStyle();
+
+ style.VerticalAlignment = VerticalAlignment.Center;
+ style.Alignment = HorizontalAlignment.Center;
+ style.WrapText = true;
+
+ var cell = row.CreateCell(1);
+ cell.CellStyle = style;
+ cell.SetCellValue(taskShiftSDto.TaskTitle);
+
+
+ var position = await _repositoryWrapper.SetRepository()
+ .TableNoTracking
+ .Where(t => t.TaskId == taskShiftSDto.TaskId)
+ .Select(TaskPositionMapper.ProjectToSDto)
+ .ToListAsync(cancellationToken);
+
+ var positionCell = row.CreateCell(2);
+ positionCell.CellStyle = style;
+ positionCell.SetCellValue(string.Join(" , ", position.Select(p => p.PositionName)));
+
+ j++;
+ }
+
+ selectedRow += count + 1;
+ }
+
+ sheet.SetColumnWidth(1, 25600);
+ sheet.SetColumnWidth(2, 7000);
+ await CreateSheetForWeek(tasks, 6, workbook);
+ for (int i = 0; i < 6; i++)
+ {
+ await CreateSheetForWeek(tasks, i, workbook);
+ }
+
+
+
+
+
+ var stream = new MemoryStream();
+ workbook.Write(stream);
+ var content = stream.ToArray();
+
+ return content;
+ }
+
+ async Task CreateSheetForWeek(List tasks, int day, XSSFWorkbook workbook)
+ {
+ var dayOfWeek = (DayOfWeek)day;
+ var sheet = workbook.CreateSheet(dayOfWeek.GetPersianDayOfWeek());
+
+ int selectedRow = 1;
+
+ CreateHeader(sheet, workbook);
+
+ sheet.IsRightToLeft = true;
+ var dayTasks = tasks.Where(t => t.Days.Any(d => d.DayOfWeek == (DayOfWeek)day)).ToList();
+
+
+
+ var shiftsTask = dayTasks.SelectMany(dt => dt.Shifts).ToList();
+ foreach (var taskShiftGrouped in shiftsTask.GroupBy(t => t.ShiftId))
+ {
+ var count = taskShiftGrouped.ToList().Count - 1;
+ var shiftName = taskShiftGrouped.FirstOrDefault()?.ShiftName ?? string.Empty;
+ CreateShiftName(selectedRow, selectedRow + count, shiftName, sheet, workbook);
+ int j = selectedRow;
+ foreach (var taskShiftSDto in taskShiftGrouped)
+ {
+
+ var row = sheet.GetRow(j) ?? sheet.CreateRow(j);
+ row.Height = 700;
+
+ var style = workbook.CreateCellStyle();
+
+ style.VerticalAlignment = VerticalAlignment.Center;
+ style.Alignment = HorizontalAlignment.Center;
+ style.WrapText = true;
+
+ var cell = row.CreateCell(1);
+ cell.CellStyle = style;
+ cell.SetCellValue(taskShiftSDto.TaskTitle);
+
+
+ var position = await _repositoryWrapper.SetRepository()
+ .TableNoTracking
+ .Where(t => t.TaskId == taskShiftSDto.TaskId)
+ .Select(TaskPositionMapper.ProjectToSDto)
+ .ToListAsync();
+
+ var positionCell = row.CreateCell(2);
+ positionCell.CellStyle = style;
+ positionCell.SetCellValue(string.Join(" , ", position.Select(p => p.PositionName)));
+
+ j++;
+ }
+
+ selectedRow = (selectedRow) + count + 1;
+ }
+ sheet.SetColumnWidth(1, 25600);
+ sheet.SetColumnWidth(2, 7000);
+ }
+
+ void CreateHeader(ISheet sheet, XSSFWorkbook workbook)
+ {
+ var headerRow = sheet.GetRow(0) ?? sheet.CreateRow(0);
+ headerRow.Height = 700;
+
+ var font = workbook.CreateFont();
+ font.IsBold = true;
+ font.Color = NPOI.HSSF.Util.HSSFColor.White.Index;
+
+ //font.FontHeight = 16;
+ var style = workbook.CreateCellStyle();
+ style.Alignment = HorizontalAlignment.Center;
+ style.VerticalAlignment = VerticalAlignment.Center;
+ style.WrapText = true;
+ style.SetFont(font);
+
+ byte[] rgb = new byte[3] { 30, 81, 123 };
+ XSSFColor color = new XSSFColor(rgb);
+ //style.SetFillBackgroundColor(color);
+ //style.SetFillForegroundColor(color);
+
+ style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.BlueGrey.Index;
+ style.FillPattern = FillPattern.SolidForeground;
+
+ var shiftNameHeaderCell = headerRow.CreateCell(0);
+ shiftNameHeaderCell.CellStyle = style;
+ shiftNameHeaderCell.SetCellValue("شیفتــ");
+
+ var taskNameHeaderCell = headerRow.CreateCell(1);
+ taskNameHeaderCell.CellStyle = style;
+ taskNameHeaderCell.SetCellValue("تسکــــ");
+
+ var positionNameHeaderCell = headerRow.CreateCell(2);
+ positionNameHeaderCell.CellStyle = style;
+ positionNameHeaderCell.SetCellValue("پوزیشن");
+ }
+
+ void CreateShiftName(int startRow, int lastRow, string name, ISheet sheet, XSSFWorkbook workbook)
+ {
+ var style = workbook.CreateCellStyle();
+ var font = workbook.CreateFont();
+ font.IsBold = true;
+ style.Alignment = HorizontalAlignment.Center;
+ style.VerticalAlignment = VerticalAlignment.Center;
+ style.WrapText = true;
+ style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Gold.Index;
+ style.FillPattern = FillPattern.SolidForeground;
+ style.SetFont(font);
+ if (lastRow > startRow)
+ {
+ sheet.AddMergedRegion(new CellRangeAddress(startRow, lastRow, 0, 0));
+
+ var rowHeader = sheet.CreateRow(startRow);
+ style.Rotation = 90;
+ var cell = rowHeader.CreateCell(0);
+ cell.SetCellValue(name);
+ cell.CellStyle = style;
+
+ }
+ else
+ {
+ var rowHeader = sheet.CreateRow(startRow);
+
+ var cell = rowHeader.CreateCell(0);
+ cell.SetCellValue(name);
+ cell.CellStyle = style;
+ }
+ }
+}
diff --git a/Brizco.Core/EntityServices/ComplexService.cs b/Brizco.Core/EntityServices/ComplexService.cs
index 90ad79b..1941bcc 100644
--- a/Brizco.Core/EntityServices/ComplexService.cs
+++ b/Brizco.Core/EntityServices/ComplexService.cs
@@ -36,6 +36,23 @@ public class ComplexService : IComplexService
foreach (var claim in ApplicationClaims.ManagerClaims)
await _roleManager.AddClaimAsync(managerRole, claim);
+
+
+ var viewOwnerRole = new ApplicationRole
+ {
+ ComplexId = complex.Id,
+ EnglishName = "ViewerOwner",
+ PersianName = "ناظر",
+ Description = "ناظر مجموعه",
+ Name = $"ViewerOwner_{complex.Id.ToString()}"
+ };
+ var createViewerResult = await _roleManager.CreateAsync(viewOwnerRole);
+ if (!createViewerResult.Succeeded)
+ throw new AppException(string.Join('|', createViewerResult.Errors));
+
+ foreach (var claim in ApplicationClaims.ManagerClaims)
+ await _roleManager.AddClaimAsync(viewOwnerRole, claim);
+
var superVisorRole = new ApplicationRole
{
ComplexId = complex.Id,
diff --git a/Brizco.Domain/Brizco.Domain.csproj b/Brizco.Domain/Brizco.Domain.csproj
index a5e938a..9176cdc 100644
--- a/Brizco.Domain/Brizco.Domain.csproj
+++ b/Brizco.Domain/Brizco.Domain.csproj
@@ -11,7 +11,7 @@
-
+
-->
diff --git a/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs b/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs
index d88a68d..69e38f0 100644
--- a/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs
+++ b/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs
@@ -1,9 +1,9 @@
namespace Brizco.Domain.CommandQueries.Commands;
-public record CreateShiftPlanCommand(long PlanDate,Guid ShiftId,Guid RoutineId, List> UserAndPositionIds)
+public record CreateShiftPlanCommand(long PlanDate,Guid ShiftId,Guid RoutineId,Guid SupervisionUserId, List> UserAndPositionIds)
:IRequest;
-public record UpdateShiftPlanCommand(Guid Id,long PlanDate, Guid ShiftId, Guid RoutineId, List> UserAndPositionIds)
+public record UpdateShiftPlanCommand(Guid Id,long PlanDate, Guid ShiftId, Guid RoutineId, Guid SupervisionUserId, List> UserAndPositionIds)
: IRequest;
public record DeleteShiftPlanCommand(Guid Id)
diff --git a/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs b/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs
index a90d57d..46be1e6 100644
--- a/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs
+++ b/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs
@@ -6,9 +6,11 @@ public class ShiftPlanLDto : BaseDto
{
public DateTime PlanFor { get; set; }
public Guid RoutineId { get; set; }
- public bool IsCompleted { get; internal set; }
- public int CompletePercent { get; internal set; }
- public string CompleteDescription { get; internal set; } = string.Empty;
+ public bool IsCompleted { get; set; }
+ public int CompletePercent { get; set; }
+ public string CompleteDescription { get; set; } = string.Empty;
public Guid ShiftId { get; set; }
public List Users { get; set; } = new();
+ public Guid SupervisorId { get; set; }
+ public string SupervisorFullName { get; set; } = string.Empty;
}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/SmallDtos/TaskPositionSDto.cs b/Brizco.Domain/Dtos/SmallDtos/TaskPositionSDto.cs
index ea6009f..c3fa89e 100644
--- a/Brizco.Domain/Dtos/SmallDtos/TaskPositionSDto.cs
+++ b/Brizco.Domain/Dtos/SmallDtos/TaskPositionSDto.cs
@@ -5,5 +5,6 @@ namespace Brizco.Domain.Dtos.SmallDtos;
public class TaskPositionSDto : BaseDto
{
public Guid PositionId { get; set; }
+ public string PositionName { get; set; } = string.Empty;
public Guid TaskId { get; set; }
}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/SmallDtos/TaskShiftSDto.cs b/Brizco.Domain/Dtos/SmallDtos/TaskShiftSDto.cs
index 3bf410a..3c74483 100644
--- a/Brizco.Domain/Dtos/SmallDtos/TaskShiftSDto.cs
+++ b/Brizco.Domain/Dtos/SmallDtos/TaskShiftSDto.cs
@@ -1,7 +1,9 @@
namespace Brizco.Domain.Dtos.SmallDtos;
-public class TaskShiftSDto
+public class TaskShiftSDto : BaseDto
{
public Guid ShiftId { get; set; }
+ public string ShiftName { get; set; } = string.Empty;
public Guid TaskId { get; set; }
+ public string TaskTitle { get; set; } = string.Empty;
}
\ No newline at end of file
diff --git a/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs b/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs
index da97850..b3a650b 100644
--- a/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs
+++ b/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs
@@ -14,9 +14,9 @@ public partial class Shift
this.Days.Add(shiftDay);
return shiftDay;
}
- public ShiftPlan AddPlan(DateTime planDate,Guid routineId)
+ public ShiftPlan AddPlan(DateTime planDate,Guid routineId , Guid superVisorId)
{
- var plan = new ShiftPlan(planDate , routineId, Id ,this.ComplexId);
+ var plan = new ShiftPlan(planDate , routineId, Id, superVisorId, this.ComplexId);
Plans.Add(plan);
return plan;
}
diff --git a/Brizco.Domain/Entities/Shift/ShiftPlan.cs b/Brizco.Domain/Entities/Shift/ShiftPlan.cs
index a159c93..4b18e4d 100644
--- a/Brizco.Domain/Entities/Shift/ShiftPlan.cs
+++ b/Brizco.Domain/Entities/Shift/ShiftPlan.cs
@@ -1,4 +1,6 @@
-namespace Brizco.Domain.Entities.Shift;
+using Brizco.Domain.Entities.User;
+
+namespace Brizco.Domain.Entities.Shift;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)]
@@ -11,11 +13,12 @@ public partial class ShiftPlan : ApiEntity
}
- internal ShiftPlan(DateTime planFor, Guid routineId,Guid shiftId, Guid complexId)
+ internal ShiftPlan(DateTime planFor, Guid routineId,Guid shiftId,Guid supervisionId, Guid complexId)
{
PlanFor = planFor;
RoutineId = routineId;
ShiftId = shiftId;
+ SupervisorId = supervisionId;
ComplexId = complexId;
}
public DateTime PlanFor { get; internal set; }
@@ -33,5 +36,8 @@ public partial class ShiftPlan : ApiEntity
public Guid ComplexId { get; internal set; }
public Complex.Complex? Complex { get; internal set; }
+ public Guid SupervisorId { get; internal set; }
+ public ApplicationUser? Supervisor { get; internal set; }
+
public List Users { get; internal set; } = new();
}
\ No newline at end of file
diff --git a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs
index bff8cf5..d60323d 100644
--- a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs
+++ b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs
@@ -4,7 +4,10 @@ using System.Linq;
using System.Linq.Expressions;
using Brizco.Domain.Dtos.LargDtos;
using Brizco.Domain.Dtos.SmallDtos;
+using Brizco.Domain.Entities.Routine;
using Brizco.Domain.Entities.Shift;
+using Brizco.Domain.Entities.User;
+using Mapster.Models;
namespace Brizco.Domain.Mappers
{
@@ -98,7 +101,11 @@ namespace Brizco.Domain.Mappers
CompletePercent = p9.CompletePercent,
CompleteDescription = p9.CompleteDescription,
ShiftId = p9.ShiftId,
+ Shift = new Shift() {Id = p9.ShiftId},
RoutineId = p9.RoutineId,
+ Routine = new Routine() {Id = p9.RoutineId},
+ SupervisorId = p9.SupervisorId,
+ Supervisor = new ApplicationUser() {Id = p9.SupervisorId},
Users = funcMain1(p9.Users),
Id = p9.Id
};
@@ -116,61 +123,71 @@ namespace Brizco.Domain.Mappers
result.CompletePercent = p11.CompletePercent;
result.CompleteDescription = p11.CompleteDescription;
result.ShiftId = p11.ShiftId;
+ result.Shift = funcMain2(new Never(), result.Shift, p11);
result.RoutineId = p11.RoutineId;
- result.Users = funcMain2(p11.Users, result.Users);
+ result.Routine = funcMain3(new Never(), result.Routine, p11);
+ result.SupervisorId = p11.SupervisorId;
+ result.Supervisor = funcMain4(new Never(), result.Supervisor, p11);
+ result.Users = funcMain5(p11.Users, result.Users);
result.Id = p11.Id;
return result;
}
- public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p15)
+ public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p21)
{
- return p15 == null ? null : new ShiftPlanLDto()
+ return p21 == null ? null : new ShiftPlanLDto()
{
- PlanFor = p15.PlanFor,
- RoutineId = p15.RoutineId,
- IsCompleted = p15.IsCompleted,
- CompletePercent = p15.CompletePercent,
- CompleteDescription = p15.CompleteDescription,
- ShiftId = p15.ShiftId,
- Users = funcMain3(p15.Users),
- Id = p15.Id
+ PlanFor = p21.PlanFor,
+ RoutineId = p21.RoutineId,
+ IsCompleted = p21.IsCompleted,
+ CompletePercent = p21.CompletePercent,
+ CompleteDescription = p21.CompleteDescription,
+ ShiftId = p21.ShiftId,
+ Users = funcMain6(p21.Users),
+ SupervisorId = p21.SupervisorId,
+ SupervisorFullName = p21.Supervisor != null ? p21.Supervisor.FirstName + " " + p21.Supervisor.LastName : string.Empty,
+ Id = p21.Id
};
}
- public static ShiftPlanLDto AdaptTo(this ShiftPlan p17, ShiftPlanLDto p18)
+ public static ShiftPlanLDto AdaptTo(this ShiftPlan p23, ShiftPlanLDto p24)
{
- if (p17 == null)
+ if (p23 == null)
{
return null;
}
- ShiftPlanLDto result = p18 ?? new ShiftPlanLDto();
+ ShiftPlanLDto result = p24 ?? new ShiftPlanLDto();
- result.PlanFor = p17.PlanFor;
- result.RoutineId = p17.RoutineId;
- result.IsCompleted = p17.IsCompleted;
- result.CompletePercent = p17.CompletePercent;
- result.CompleteDescription = p17.CompleteDescription;
- result.ShiftId = p17.ShiftId;
- result.Users = funcMain4(p17.Users, result.Users);
- result.Id = p17.Id;
+ result.PlanFor = p23.PlanFor;
+ result.RoutineId = p23.RoutineId;
+ result.IsCompleted = p23.IsCompleted;
+ result.CompletePercent = p23.CompletePercent;
+ result.CompleteDescription = p23.CompleteDescription;
+ result.ShiftId = p23.ShiftId;
+ result.Users = funcMain7(p23.Users, result.Users);
+ result.SupervisorId = p23.SupervisorId;
+ result.SupervisorFullName = p23.Supervisor != null ? p23.Supervisor.FirstName + " " + p23.Supervisor.LastName : string.Empty;
+ result.Id = p23.Id;
return result;
}
- public static Expression> ProjectToLDto => p21 => new ShiftPlanLDto()
+ public static Expression> ProjectToLDto => p27 => new ShiftPlanLDto()
{
- PlanFor = p21.PlanFor,
- RoutineId = p21.RoutineId,
- IsCompleted = p21.IsCompleted,
- CompletePercent = p21.CompletePercent,
- CompleteDescription = p21.CompleteDescription,
- ShiftId = p21.ShiftId,
- Users = p21.Users.Select(p22 => new ShiftPlanUserSDto()
+ PlanFor = p27.PlanFor,
+ RoutineId = p27.RoutineId,
+ IsCompleted = p27.IsCompleted,
+ CompletePercent = p27.CompletePercent,
+ CompleteDescription = p27.CompleteDescription,
+ ShiftId = p27.ShiftId,
+ Users = p27.Users.Select(p28 => new ShiftPlanUserSDto()
{
- ShiftPlanId = p22.ShiftPlanId,
- UserId = p22.UserId,
- PositionId = p22.PositionId,
- Id = p22.Id
+ ShiftPlanId = p28.ShiftPlanId,
+ UserId = p28.UserId,
+ PositionId = p28.PositionId,
+ Id = p28.Id
}).ToList(),
- Id = p21.Id
+ SupervisorId = p27.SupervisorId,
+ SupervisorFullName = p27.Supervisor != null ? p27.Supervisor.FirstName + " " + p27.Supervisor.LastName : string.Empty,
+ Id = p27.Id
};
private static List funcMain1(List p10)
@@ -200,20 +217,47 @@ namespace Brizco.Domain.Mappers
}
- private static List funcMain2(List p13, List p14)
+ private static Shift funcMain2(Never p13, Shift p14, ShiftPlanLDto p11)
{
- if (p13 == null)
+ Shift result = p14 ?? new Shift();
+
+ result.Id = p11.ShiftId;
+ return result;
+
+ }
+
+ private static Routine funcMain3(Never p15, Routine p16, ShiftPlanLDto p11)
+ {
+ Routine result = p16 ?? new Routine();
+
+ result.Id = p11.RoutineId;
+ return result;
+
+ }
+
+ private static ApplicationUser funcMain4(Never p17, ApplicationUser p18, ShiftPlanLDto p11)
+ {
+ ApplicationUser result = p18 ?? new ApplicationUser();
+
+ result.Id = p11.SupervisorId;
+ return result;
+
+ }
+
+ private static List funcMain5(List p19, List p20)
+ {
+ if (p19 == null)
{
return null;
}
- List result = new List(p13.Count);
+ List result = new List(p19.Count);
int i = 0;
- int len = p13.Count;
+ int len = p19.Count;
while (i < len)
{
- ShiftPlanUserSDto item = p13[i];
+ ShiftPlanUserSDto item = p19[i];
result.Add(item == null ? null : new ShiftPlanUser()
{
ShiftPlanId = item.ShiftPlanId,
@@ -227,20 +271,20 @@ namespace Brizco.Domain.Mappers
}
- private static List funcMain3(List p16)
+ private static List funcMain6(List p22)
{
- if (p16 == null)
+ if (p22 == null)
{
return null;
}
- List result = new List(p16.Count);
+ List result = new List(p22.Count);
int i = 0;
- int len = p16.Count;
+ int len = p22.Count;
while (i < len)
{
- ShiftPlanUser item = p16[i];
+ ShiftPlanUser item = p22[i];
result.Add(item == null ? null : new ShiftPlanUserSDto()
{
ShiftPlanId = item.ShiftPlanId,
@@ -254,20 +298,20 @@ namespace Brizco.Domain.Mappers
}
- private static List funcMain4(List p19, List p20)
+ private static List funcMain7(List p25, List p26)
{
- if (p19 == null)
+ if (p25 == null)
{
return null;
}
- List result = new List(p19.Count);
+ List result = new List(p25.Count);
int i = 0;
- int len = p19.Count;
+ int len = p25.Count;
while (i < len)
{
- ShiftPlanUser item = p19[i];
+ ShiftPlanUser item = p25[i];
result.Add(item == null ? null : new ShiftPlanUserSDto()
{
ShiftPlanId = item.ShiftPlanId,
diff --git a/Brizco.Domain/Mappers/TaskMapper.g.cs b/Brizco.Domain/Mappers/TaskMapper.g.cs
index b51c4a8..866fa14 100644
--- a/Brizco.Domain/Mappers/TaskMapper.g.cs
+++ b/Brizco.Domain/Mappers/TaskMapper.g.cs
@@ -6,6 +6,7 @@ using Brizco.Common.Extensions;
using Brizco.Domain.Dtos.LargDtos;
using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.Complex;
+using Brizco.Domain.Entities.Shift;
using Brizco.Domain.Entities.Task;
using Mapster.Models;
using Task = Brizco.Domain.Entities.Task.Task;
@@ -245,11 +246,15 @@ namespace Brizco.Domain.Mappers
Shifts = p62.Shifts.Select(p63 => new TaskShiftSDto()
{
ShiftId = p63.ShiftId,
- TaskId = p63.TaskId
+ ShiftName = p63.Shift != null ? p63.Shift.Title : string.Empty,
+ TaskId = p63.TaskId,
+ TaskTitle = p63.Task != null ? p63.Task.Title : string.Empty,
+ Id = p63.Id
}).ToList(),
Positions = p62.Positions.Select(p64 => new TaskPositionSDto()
{
PositionId = p64.PositionId,
+ PositionName = p64.Position != null ? p64.Position.Name : string.Empty,
TaskId = p64.TaskId,
Id = p64.Id
}).ToList(),
@@ -549,7 +554,14 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskShift()
{
TaskId = item.TaskId,
- ShiftId = item.ShiftId
+ Task = new Task()
+ {
+ Title = item.TaskTitle,
+ Id = item.TaskId
+ },
+ ShiftId = item.ShiftId,
+ Shift = new Shift() {Id = item.ShiftId},
+ Id = item.Id
});
i++;
}
@@ -626,7 +638,13 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskPosition()
{
PositionId = item.PositionId,
+ Position = new Position()
+ {
+ Name = item.PositionName,
+ Id = item.PositionId
+ },
TaskId = item.TaskId,
+ Task = new Task() {Id = item.TaskId},
Id = item.Id
});
i++;
@@ -652,7 +670,14 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskShift()
{
TaskId = item.TaskId,
- ShiftId = item.ShiftId
+ Task = new Task()
+ {
+ Title = item.TaskTitle,
+ Id = item.TaskId
+ },
+ ShiftId = item.ShiftId,
+ Shift = new Shift() {Id = item.ShiftId},
+ Id = item.Id
});
i++;
}
@@ -729,7 +754,13 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskPosition()
{
PositionId = item.PositionId,
+ Position = new Position()
+ {
+ Name = item.PositionName,
+ Id = item.PositionId
+ },
TaskId = item.TaskId,
+ Task = new Task() {Id = item.TaskId},
Id = item.Id
});
i++;
@@ -755,7 +786,10 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskShiftSDto()
{
ShiftId = item.ShiftId,
- TaskId = item.TaskId
+ ShiftName = item.Shift != null ? item.Shift.Title : string.Empty,
+ TaskId = item.TaskId,
+ TaskTitle = item.Task != null ? item.Task.Title : string.Empty,
+ Id = item.Id
});
i++;
}
@@ -780,6 +814,7 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskPositionSDto()
{
PositionId = item.PositionId,
+ PositionName = item.Position != null ? item.Position.Name : string.Empty,
TaskId = item.TaskId,
Id = item.Id
});
@@ -858,7 +893,10 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskShiftSDto()
{
ShiftId = item.ShiftId,
- TaskId = item.TaskId
+ ShiftName = item.Shift != null ? item.Shift.Title : string.Empty,
+ TaskId = item.TaskId,
+ TaskTitle = item.Task != null ? item.Task.Title : string.Empty,
+ Id = item.Id
});
i++;
}
@@ -883,6 +921,7 @@ namespace Brizco.Domain.Mappers
result.Add(item == null ? null : new TaskPositionSDto()
{
PositionId = item.PositionId,
+ PositionName = item.Position != null ? item.Position.Name : string.Empty,
TaskId = item.TaskId,
Id = item.Id
});
diff --git a/Brizco.Domain/Mappers/TaskPositionMapper.g.cs b/Brizco.Domain/Mappers/TaskPositionMapper.g.cs
index 7f8fd68..def20a6 100644
--- a/Brizco.Domain/Mappers/TaskPositionMapper.g.cs
+++ b/Brizco.Domain/Mappers/TaskPositionMapper.g.cs
@@ -1,7 +1,10 @@
using System;
using System.Linq.Expressions;
using Brizco.Domain.Dtos.SmallDtos;
+using Brizco.Domain.Entities.Complex;
using Brizco.Domain.Entities.Task;
+using Mapster.Models;
+using Task = Brizco.Domain.Entities.Task.Task;
namespace Brizco.Domain.Mappers
{
@@ -12,7 +15,13 @@ namespace Brizco.Domain.Mappers
return p1 == null ? null : new TaskPosition()
{
PositionId = p1.PositionId,
+ Position = new Position()
+ {
+ Name = p1.PositionName,
+ Id = p1.PositionId
+ },
TaskId = p1.TaskId,
+ Task = new Task() {Id = p1.TaskId},
Id = p1.Id
};
}
@@ -25,45 +34,75 @@ namespace Brizco.Domain.Mappers
TaskPosition result = p3 ?? new TaskPosition();
result.PositionId = p2.PositionId;
+ result.Position = funcMain1(new Never(), result.Position, p2);
result.TaskId = p2.TaskId;
+ result.Task = funcMain2(new Never(), result.Task, p2);
result.Id = p2.Id;
return result;
}
- public static Expression> ProjectToTaskPosition => p4 => new TaskPosition()
+ public static Expression> ProjectToTaskPosition => p8 => new TaskPosition()
{
- PositionId = p4.PositionId,
- TaskId = p4.TaskId,
- Id = p4.Id
- };
- public static TaskPositionSDto AdaptToSDto(this TaskPosition p5)
- {
- return p5 == null ? null : new TaskPositionSDto()
+ PositionId = p8.PositionId,
+ Position = new Position()
{
- PositionId = p5.PositionId,
- TaskId = p5.TaskId,
- Id = p5.Id
+ Name = p8.PositionName,
+ Id = p8.PositionId
+ },
+ TaskId = p8.TaskId,
+ Task = new Task() {Id = p8.TaskId},
+ Id = p8.Id
+ };
+ public static TaskPositionSDto AdaptToSDto(this TaskPosition p9)
+ {
+ return p9 == null ? null : new TaskPositionSDto()
+ {
+ PositionId = p9.PositionId,
+ PositionName = p9.Position != null ? p9.Position.Name : string.Empty,
+ TaskId = p9.TaskId,
+ Id = p9.Id
};
}
- public static TaskPositionSDto AdaptTo(this TaskPosition p6, TaskPositionSDto p7)
+ public static TaskPositionSDto AdaptTo(this TaskPosition p10, TaskPositionSDto p11)
{
- if (p6 == null)
+ if (p10 == null)
{
return null;
}
- TaskPositionSDto result = p7 ?? new TaskPositionSDto();
+ TaskPositionSDto result = p11 ?? new TaskPositionSDto();
- result.PositionId = p6.PositionId;
- result.TaskId = p6.TaskId;
- result.Id = p6.Id;
+ result.PositionId = p10.PositionId;
+ result.PositionName = p10.Position != null ? p10.Position.Name : string.Empty;
+ result.TaskId = p10.TaskId;
+ result.Id = p10.Id;
return result;
}
- public static Expression> ProjectToSDto => p8 => new TaskPositionSDto()
+ public static Expression> ProjectToSDto => p12 => new TaskPositionSDto()
{
- PositionId = p8.PositionId,
- TaskId = p8.TaskId,
- Id = p8.Id
+ PositionId = p12.PositionId,
+ PositionName = p12.Position != null ? p12.Position.Name : string.Empty,
+ TaskId = p12.TaskId,
+ Id = p12.Id
};
+
+ private static Position funcMain1(Never p4, Position p5, TaskPositionSDto p2)
+ {
+ Position result = p5 ?? new Position();
+
+ result.Name = p2.PositionName;
+ result.Id = p2.PositionId;
+ return result;
+
+ }
+
+ private static Task funcMain2(Never p6, Task p7, TaskPositionSDto p2)
+ {
+ Task result = p7 ?? new Task();
+
+ result.Id = p2.TaskId;
+ return result;
+
+ }
}
}
\ No newline at end of file
diff --git a/Brizco.Domain/Mappers/TaskShiftMapper.g.cs b/Brizco.Domain/Mappers/TaskShiftMapper.g.cs
index 202af45..c3d8642 100644
--- a/Brizco.Domain/Mappers/TaskShiftMapper.g.cs
+++ b/Brizco.Domain/Mappers/TaskShiftMapper.g.cs
@@ -1,7 +1,10 @@
using System;
using System.Linq.Expressions;
using Brizco.Domain.Dtos.SmallDtos;
+using Brizco.Domain.Entities.Shift;
using Brizco.Domain.Entities.Task;
+using Mapster.Models;
+using Task = Brizco.Domain.Entities.Task.Task;
namespace Brizco.Domain.Mappers
{
@@ -12,7 +15,14 @@ namespace Brizco.Domain.Mappers
return p1 == null ? null : new TaskShift()
{
TaskId = p1.TaskId,
- ShiftId = p1.ShiftId
+ Task = new Task()
+ {
+ Title = p1.TaskTitle,
+ Id = p1.TaskId
+ },
+ ShiftId = p1.ShiftId,
+ Shift = new Shift() {Id = p1.ShiftId},
+ Id = p1.Id
};
}
public static TaskShift AdaptTo(this TaskShiftSDto p2, TaskShift p3)
@@ -24,40 +34,78 @@ namespace Brizco.Domain.Mappers
TaskShift result = p3 ?? new TaskShift();
result.TaskId = p2.TaskId;
+ result.Task = funcMain1(new Never(), result.Task, p2);
result.ShiftId = p2.ShiftId;
+ result.Shift = funcMain2(new Never(), result.Shift, p2);
+ result.Id = p2.Id;
return result;
}
- public static Expression> ProjectToTaskShift => p4 => new TaskShift()
+ public static Expression> ProjectToTaskShift => p8 => new TaskShift()
{
- TaskId = p4.TaskId,
- ShiftId = p4.ShiftId
- };
- public static TaskShiftSDto AdaptToSDto(this TaskShift p5)
- {
- return p5 == null ? null : new TaskShiftSDto()
+ TaskId = p8.TaskId,
+ Task = new Task()
{
- ShiftId = p5.ShiftId,
- TaskId = p5.TaskId
+ Title = p8.TaskTitle,
+ Id = p8.TaskId
+ },
+ ShiftId = p8.ShiftId,
+ Shift = new Shift() {Id = p8.ShiftId},
+ Id = p8.Id
+ };
+ public static TaskShiftSDto AdaptToSDto(this TaskShift p9)
+ {
+ return p9 == null ? null : new TaskShiftSDto()
+ {
+ ShiftId = p9.ShiftId,
+ ShiftName = p9.Shift != null ? p9.Shift.Title : string.Empty,
+ TaskId = p9.TaskId,
+ TaskTitle = p9.Task != null ? p9.Task.Title : string.Empty,
+ Id = p9.Id
};
}
- public static TaskShiftSDto AdaptTo(this TaskShift p6, TaskShiftSDto p7)
+ public static TaskShiftSDto AdaptTo(this TaskShift p10, TaskShiftSDto p11)
{
- if (p6 == null)
+ if (p10 == null)
{
return null;
}
- TaskShiftSDto result = p7 ?? new TaskShiftSDto();
+ TaskShiftSDto result = p11 ?? new TaskShiftSDto();
- result.ShiftId = p6.ShiftId;
- result.TaskId = p6.TaskId;
+ result.ShiftId = p10.ShiftId;
+ result.ShiftName = p10.Shift != null ? p10.Shift.Title : string.Empty;
+ result.TaskId = p10.TaskId;
+ result.TaskTitle = p10.Task != null ? p10.Task.Title : string.Empty;
+ result.Id = p10.Id;
return result;
}
- public static Expression> ProjectToSDto => p8 => new TaskShiftSDto()
+ public static Expression> ProjectToSDto => p12 => new TaskShiftSDto()
{
- ShiftId = p8.ShiftId,
- TaskId = p8.TaskId
+ ShiftId = p12.ShiftId,
+ ShiftName = p12.Shift != null ? p12.Shift.Title : string.Empty,
+ TaskId = p12.TaskId,
+ TaskTitle = p12.Task != null ? p12.Task.Title : string.Empty,
+ Id = p12.Id
};
+
+ private static Task funcMain1(Never p4, Task p5, TaskShiftSDto p2)
+ {
+ Task result = p5 ?? new Task();
+
+ result.Title = p2.TaskTitle;
+ result.Id = p2.TaskId;
+ return result;
+
+ }
+
+ private static Shift funcMain2(Never p6, Shift p7, TaskShiftSDto p2)
+ {
+ Shift result = p7 ?? new Shift();
+
+ result.Id = p2.ShiftId;
+ return result;
+
+ }
}
}
\ No newline at end of file
diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs
index f86a754..aa16e34 100644
--- a/Brizco.Domain/MapsterRegister.cs
+++ b/Brizco.Domain/MapsterRegister.cs
@@ -13,6 +13,15 @@ public class MapsterRegister : IRegister
.Map("Positions", o => o.Positions.Select(d => d.Position != null ? d.Position.Name : string.Empty))
.TwoWays();
+ config.NewConfig()
+ .Map("ShiftName", o => o.Shift != null ? o.Shift.Title : string.Empty)
+ .Map("TaskTitle", o => o.Task != null ? o.Task.Title : string.Empty)
+ .TwoWays();
+
+ config.NewConfig()
+ .Map("PositionName", o => o.Position != null ? o.Position.Name : string.Empty)
+ .TwoWays();
+
config.NewConfig()
.Map("UserFirstName", o => o.User !=null ? o.User.FirstName : string.Empty)
.Map("UserLastName", o => o.User != null ? o.User.LastName : string.Empty)
@@ -31,6 +40,10 @@ public class MapsterRegister : IRegister
.Map("Days", o => o.Days.Select(d => d.DayOfWeek).ToList())
.TwoWays();
+ config.NewConfig()
+ .Map("SupervisorFullName", o => o.Supervisor != null ? o.Supervisor.FirstName + " " + o.Supervisor.LastName : string.Empty)
+ .TwoWays();
+
config.NewConfig()
.Map("RoleName", org => org.Role!.PersianName)
.TwoWays();
diff --git a/Brizco.Repository/Brizco.Repository.csproj b/Brizco.Repository/Brizco.Repository.csproj
index 9a14425..65a1def 100644
--- a/Brizco.Repository/Brizco.Repository.csproj
+++ b/Brizco.Repository/Brizco.Repository.csproj
@@ -8,22 +8,22 @@
-
+
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
+
+
+
+
diff --git a/Brizco.Repository/Extensions/ModelBuilderExtensions.cs b/Brizco.Repository/Extensions/ModelBuilderExtensions.cs
index eb23de4..61c39a4 100644
--- a/Brizco.Repository/Extensions/ModelBuilderExtensions.cs
+++ b/Brizco.Repository/Extensions/ModelBuilderExtensions.cs
@@ -79,7 +79,10 @@ public static class ModelBuilderExtensions
.SelectMany(t => t.GetForeignKeys())
.Where(fk => !fk.IsOwnership && fk.DeleteBehavior == DeleteBehavior.Cascade);
foreach (var fk in cascadeFKs)
+ {
fk.DeleteBehavior = DeleteBehavior.Restrict;
+ fk.IsRequired = false;
+ }
}
///
diff --git a/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs b/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs
index ae05e16..4a5bdcc 100644
--- a/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs
+++ b/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs
@@ -29,7 +29,7 @@ public class CreateShiftPlanCommandHandler : IRequestHandler
+using System;
+using Brizco.Repository.Models;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace Brizco.Repository.Migrations
+{
+ [DbContext(typeof(ApplicationContext))]
+ [Migration("20240214082856_EditShiftPlanAddSuperVisior")]
+ partial class EditShiftPlanAddSuperVisior
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasDefaultSchema("public")
+ .HasAnnotation("ProductVersion", "8.0.0")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Address")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("SupportPhone")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Complexes", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("ComplexId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComplexId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("ComplexUsers", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUserRole", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("ComplexUserId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("RoleId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComplexUserId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("ComplexUserRoles", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("ComplexId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("SectionId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComplexId");
+
+ b.HasIndex("SectionId");
+
+ b.ToTable("Positions", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("ComplexId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComplexId");
+
+ b.ToTable("Sections", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("ComplexId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComplexId");
+
+ b.ToTable("Routines", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("ComplexId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("EndAt")
+ .HasColumnType("interval");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("StartAt")
+ .HasColumnType("interval");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComplexId");
+
+ b.ToTable("Shifts", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("DayOfWeek")
+ .HasColumnType("integer");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("ShiftId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ShiftId");
+
+ b.ToTable("ShiftDays", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CompleteDescription")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("CompletePercent")
+ .HasColumnType("integer");
+
+ b.Property("ComplexId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("IsCompleted")
+ .HasColumnType("boolean");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("PlanFor")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("RoutineId")
+ .HasColumnType("uuid");
+
+ b.Property("ShiftId")
+ .HasColumnType("uuid");
+
+ b.Property("SupervisorId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComplexId");
+
+ b.HasIndex("RoutineId");
+
+ b.HasIndex("ShiftId");
+
+ b.HasIndex("SupervisorId");
+
+ b.ToTable("ShiftPlans", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("PositionId")
+ .HasColumnType("uuid");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("ShiftPlanId")
+ .HasColumnType("uuid");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PositionId");
+
+ b.HasIndex("ShiftPlanId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("ShiftPlanUsers", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftRoutine", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("RoutineId")
+ .HasColumnType("uuid");
+
+ b.Property("ShiftId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoutineId");
+
+ b.HasIndex("ShiftId");
+
+ b.ToTable("ShiftRoutines", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Amount")
+ .HasColumnType("integer");
+
+ b.Property("AmountType")
+ .HasColumnType("integer");
+
+ b.Property("ComplexId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Discriminator")
+ .IsRequired()
+ .HasMaxLength(8)
+ .HasColumnType("character varying(8)");
+
+ b.Property("HasDisposed")
+ .HasColumnType("boolean");
+
+ b.Property("IsActivity")
+ .HasColumnType("boolean");
+
+ b.Property("IsDisposable")
+ .HasColumnType("boolean");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("ScheduleType")
+ .HasColumnType("integer");
+
+ b.Property("SetFor")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("Title")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComplexId");
+
+ b.ToTable("Tasks", "public");
+
+ b.HasDiscriminator("Discriminator").HasValue("Task");
+
+ b.UseTphMappingStrategy();
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("DayOfWeek")
+ .HasColumnType("integer");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("TaskId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TaskId");
+
+ b.ToTable("TaskDays", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskPosition", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ModifiedBy")
+ .HasColumnType("text");
+
+ b.Property("PositionId")
+ .HasColumnType("uuid");
+
+ b.Property("RemovedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("RemovedBy")
+ .HasColumnType("text");
+
+ b.Property("TaskId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PositionId");
+
+ b.HasIndex("TaskId");
+
+ b.ToTable("TaskPositions", "public");
+ });
+
+ modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRoutine", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text");
+
+ b.Property("IsRemoved")
+ .HasColumnType("boolean");
+
+ b.Property("ModifiedAt")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property