From 81cb0e8df3b8bd2b5da5f61a7c6f8ceb52ac22ba Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Sun, 19 Nov 2023 22:06:49 +0330 Subject: [PATCH] add version 0.1.3.1 --- .version | 2 +- Brizco.Api/Brizco.Api.csproj | 4 +- Brizco.Api/Controllers/ComplexController.cs | 2 +- Brizco.Api/Controllers/RoutineController.cs | 8 + Brizco.Api/Controllers/ShiftPlanController.cs | 2 +- Brizco.Api/Controllers/TaskController.cs | 4 +- Brizco.Domain/Brizco.Domain.csproj | 1 + .../Commands/PositionCommands.cs | 9 - .../Commands/RoutineCommands.cs | 4 +- .../Commands/ShiftPlanCommands.cs | 4 +- .../CommandQueries/Queries/RoutineQueries.cs | 5 +- Brizco.Domain/Dtos/LargDtos/PositionLDto.cs | 2 - Brizco.Domain/Dtos/LargDtos/TaskLDto.cs | 2 +- .../ResponseDto/RoutineShiftResponseDto.cs | 7 + .../Dtos/SmallDtos/PositionUserSDto.cs | 7 - .../Dtos/SmallDtos/ShiftPlanUserSDto.cs | 3 +- Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs | 5 +- .../Entities/Complex/Aggregate.Complex.cs | 14 - Brizco.Domain/Entities/Complex/Position.cs | 2 - .../Entities/Complex/PositionUser.cs | 27 - .../Entities/Shift/Aggregate.Shift.cs | 8 +- Brizco.Domain/Entities/Shift/ShiftPlan.cs | 10 +- Brizco.Domain/Entities/Shift/ShiftPlanUser.cs | 12 +- Brizco.Domain/Entities/Task/TaskPosition.cs | 2 +- Brizco.Domain/Mappers/PositionMapper.g.cs | 250 +-- Brizco.Domain/Mappers/PositionUserMapper.g.cs | 69 - Brizco.Domain/Mappers/ShiftPlanMapper.g.cs | 18 +- .../Mappers/ShiftPlanUserMapper.g.cs | 18 +- Brizco.Domain/Mappers/TaskMapper.g.cs | 1018 +++++++---- Brizco.Domain/MapsterRegister.cs | 13 + Brizco.Repository/Brizco.Repository.csproj | 1 + .../CreatePositionUserCommandHandler.cs | 37 - .../Position/UpdatePositionCommandHandler.cs | 21 - .../UpdatePositionUserCommandHandler.cs | 37 - .../Routine/CreateRoutineCommandHandler.cs | 2 +- .../Routine/GetRoutineShiftsQueryHandler.cs | 49 + .../Routine/UpdateRoutineCommandHandler.cs | 6 +- .../CreateShiftPlanCommandHandler.cs | 13 +- .../UpdateShiftPlanCommandHandler.cs | 10 +- .../20231119064231_editShiftPlan.Designer.cs | 1511 +++++++++++++++++ .../20231119064231_editShiftPlan.cs | 70 + ...231119172529_editShiftPlanUser.Designer.cs | 1442 ++++++++++++++++ .../20231119172529_editShiftPlanUser.cs | 177 ++ .../ApplicationContextModelSnapshot.cs | 128 +- 44 files changed, 4113 insertions(+), 923 deletions(-) create mode 100644 Brizco.Domain/Dtos/ResponseDto/RoutineShiftResponseDto.cs delete mode 100644 Brizco.Domain/Dtos/SmallDtos/PositionUserSDto.cs delete mode 100644 Brizco.Domain/Entities/Complex/PositionUser.cs delete mode 100644 Brizco.Domain/Mappers/PositionUserMapper.g.cs delete mode 100644 Brizco.Repository/Handlers/Position/CreatePositionUserCommandHandler.cs delete mode 100644 Brizco.Repository/Handlers/Position/UpdatePositionUserCommandHandler.cs create mode 100644 Brizco.Repository/Handlers/Routine/GetRoutineShiftsQueryHandler.cs create mode 100644 Brizco.Repository/Migrations/20231119064231_editShiftPlan.Designer.cs create mode 100644 Brizco.Repository/Migrations/20231119064231_editShiftPlan.cs create mode 100644 Brizco.Repository/Migrations/20231119172529_editShiftPlanUser.Designer.cs create mode 100644 Brizco.Repository/Migrations/20231119172529_editShiftPlanUser.cs diff --git a/.version b/.version index 57d102a..963409b 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.1.2.0 \ No newline at end of file +0.1.3.1 \ No newline at end of file diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj index ecbbf87..c17515f 100644 --- a/Brizco.Api/Brizco.Api.csproj +++ b/Brizco.Api/Brizco.Api.csproj @@ -6,8 +6,8 @@ enable Linux ..\docker-compose.dcproj - 0.1.2.0 - 0.1.2.0 + 0.1.3.1 + 0.1.3.1 diff --git a/Brizco.Api/Controllers/ComplexController.cs b/Brizco.Api/Controllers/ComplexController.cs index cf7f85d..97b5e18 100644 --- a/Brizco.Api/Controllers/ComplexController.cs +++ b/Brizco.Api/Controllers/ComplexController.cs @@ -23,7 +23,7 @@ public class ComplexController : ICarterModule group.MapPut("", Put) .HasApiVersion(1.0); - group.MapDelete("", Delete) + group.MapDelete("{id}", Delete) .HasApiVersion(1.0); } diff --git a/Brizco.Api/Controllers/RoutineController.cs b/Brizco.Api/Controllers/RoutineController.cs index 25b2a70..65b3893 100644 --- a/Brizco.Api/Controllers/RoutineController.cs +++ b/Brizco.Api/Controllers/RoutineController.cs @@ -12,6 +12,10 @@ public class RoutineController : ICarterModule .WithDisplayName("GetAllRoutines") .HasApiVersion(1.0); + group.MapGet("{id}/shift", GetShiftsAsync) + .WithDisplayName("GetRoutineShifts") + .HasApiVersion(1.0); + group.MapGet("{id}", GetAsync) .WithDisplayName("GetRoutine") .HasApiVersion(1.0); @@ -34,6 +38,10 @@ public class RoutineController : ICarterModule public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) => TypedResults.Ok(await sender.Send(new GetRoutineQuery(id), cancellationToken)); + // GET:Get Shifts By Id + public async Task GetShiftsAsync(Guid id, ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetRoutineShiftsQuery(id), cancellationToken)); + // POST:Create Entity public async Task Post([FromBody] CreateRoutineCommand ent, ISender mediator, CancellationToken cancellationToken) => TypedResults.Ok(await mediator.Send(ent, cancellationToken)); diff --git a/Brizco.Api/Controllers/ShiftPlanController.cs b/Brizco.Api/Controllers/ShiftPlanController.cs index e0f0b9f..f297741 100644 --- a/Brizco.Api/Controllers/ShiftPlanController.cs +++ b/Brizco.Api/Controllers/ShiftPlanController.cs @@ -34,7 +34,7 @@ public class ShiftPlanController : ICarterModule // GET:Get An Entity By Id public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) - => TypedResults.Ok(await sender.Send(new GetShiftPlanQuery(id))); + => TypedResults.Ok(await sender.Send(new GetShiftPlanQuery(id),cancellationToken)); // POST:Create Entity public async Task Post([FromBody] CreateShiftPlanCommand ent, ISender mediator, CancellationToken cancellationToken) diff --git a/Brizco.Api/Controllers/TaskController.cs b/Brizco.Api/Controllers/TaskController.cs index f379916..4a0871d 100644 --- a/Brizco.Api/Controllers/TaskController.cs +++ b/Brizco.Api/Controllers/TaskController.cs @@ -25,7 +25,7 @@ public class TaskController : ICarterModule group.MapPut("", Put) .HasApiVersion(1.0); - group.MapDelete("", Delete) + group.MapDelete("{id}", Delete) .HasApiVersion(1.0); } @@ -35,7 +35,7 @@ public class TaskController : ICarterModule // GET:Get An Entity By Id public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) - => TypedResults.Ok(await sender.Send(new GetTaskQuery(id))); + => TypedResults.Ok(await sender.Send(new GetTaskQuery(id),cancellationToken)); // POST:Create Entity public async Task Post([FromBody] CreateTaskCommand ent, ISender mediator, CancellationToken cancellationToken) diff --git a/Brizco.Domain/Brizco.Domain.csproj b/Brizco.Domain/Brizco.Domain.csproj index 2bab5f5..e6ccecf 100644 --- a/Brizco.Domain/Brizco.Domain.csproj +++ b/Brizco.Domain/Brizco.Domain.csproj @@ -52,6 +52,7 @@ + diff --git a/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs b/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs index 27c763e..65a2671 100644 --- a/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs @@ -8,12 +8,3 @@ public sealed record UpdatePositionCommand(Guid Id, string Title, string Descrip public sealed record DeletePositionCommand(Guid Id) : IRequest; - -public sealed record CreatePositionUserCommand(Guid PositionId,Guid UserId, Guid ShiftPlanId) - : IRequest; - -public sealed record UpdatePositionUserCommand(Guid PositionId, Guid UserId, Guid ShiftPlanId) - : IRequest; - -public sealed record DeletePositionUserCommand(Guid PositionId, Guid UserId, Guid ShiftPlanId) - : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Commands/RoutineCommands.cs b/Brizco.Domain/CommandQueries/Commands/RoutineCommands.cs index 6257490..81ff02e 100644 --- a/Brizco.Domain/CommandQueries/Commands/RoutineCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/RoutineCommands.cs @@ -1,10 +1,10 @@ namespace Brizco.Domain.CommandQueries.Commands; -public sealed record CreateRoutineCommand(string Title, string Description) +public sealed record CreateRoutineCommand(string Name, string Description) : IRequest; -public sealed record UpdateRoutineCommand(Guid Id, string Title, string Description) +public sealed record UpdateRoutineCommand(Guid Id, string Name, string Description) : IRequest; public sealed record DeleteRoutineCommand(Guid Id) diff --git a/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs b/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs index aad000b..2fe64c5 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(DateTime PlanDate,Guid ShiftId,List UserIds) +public record CreateShiftPlanCommand(DateTime PlanDate,Guid ShiftId,Guid RoutineId, List> UserAndPositionIds) :IRequest; -public record UpdateShiftPlanCommand(Guid Id,DateTime PlanDate, Guid ShiftId, List UserIds) +public record UpdateShiftPlanCommand(Guid Id,DateTime PlanDate, Guid ShiftId, Guid RoutineId, List> UserAndPositionIds) : IRequest; public record DeleteShiftPlanCommand(Guid Id) diff --git a/Brizco.Domain/CommandQueries/Queries/RoutineQueries.cs b/Brizco.Domain/CommandQueries/Queries/RoutineQueries.cs index 7d5e24e..f888925 100644 --- a/Brizco.Domain/CommandQueries/Queries/RoutineQueries.cs +++ b/Brizco.Domain/CommandQueries/Queries/RoutineQueries.cs @@ -4,4 +4,7 @@ public sealed record GetRoutinesQuery(int Page = 0) : IRequest>; public sealed record GetRoutineQuery(Guid Id) : - IRequest; \ No newline at end of file + IRequest; + +public sealed record GetRoutineShiftsQuery(Guid Id): + IRequest>; \ No newline at end of file diff --git a/Brizco.Domain/Dtos/LargDtos/PositionLDto.cs b/Brizco.Domain/Dtos/LargDtos/PositionLDto.cs index db3cf06..a131c6f 100644 --- a/Brizco.Domain/Dtos/LargDtos/PositionLDto.cs +++ b/Brizco.Domain/Dtos/LargDtos/PositionLDto.cs @@ -10,6 +10,4 @@ public class PositionLDto : BaseDto public Guid SectionId { get; set; } public string SectionName { get; set; } = string.Empty; - - public List Users { get; set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Dtos/LargDtos/TaskLDto.cs b/Brizco.Domain/Dtos/LargDtos/TaskLDto.cs index 537579a..c1bfd0f 100644 --- a/Brizco.Domain/Dtos/LargDtos/TaskLDto.cs +++ b/Brizco.Domain/Dtos/LargDtos/TaskLDto.cs @@ -8,7 +8,7 @@ public class TaskLDto : BaseDto public string Title { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public bool IsDisposable { get; set; } - public DateTime SetFor { get; set; } + public long SetFor { get; set; } public bool HasDisposed { get; set; } public TaskScheduleType ScheduleType { get; set; } diff --git a/Brizco.Domain/Dtos/ResponseDto/RoutineShiftResponseDto.cs b/Brizco.Domain/Dtos/ResponseDto/RoutineShiftResponseDto.cs new file mode 100644 index 0000000..9b4d2b4 --- /dev/null +++ b/Brizco.Domain/Dtos/ResponseDto/RoutineShiftResponseDto.cs @@ -0,0 +1,7 @@ +namespace Brizco.Domain.Dtos.ResponseDto; + +public class RoutineShiftResponseDto +{ + public DayOfWeek Day { get; set; } + public List Shifts { get; set; } = new(); +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/PositionUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/PositionUserSDto.cs deleted file mode 100644 index cd278c5..0000000 --- a/Brizco.Domain/Dtos/SmallDtos/PositionUserSDto.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Brizco.Domain.Dtos.SmallDtos; - -public class PositionUserSDto : BaseDto -{ - public Guid ApplicationUserId { get; set; } - public Guid PositionId { get; set; } -} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs index d77fa54..7f5fd1f 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs @@ -5,5 +5,6 @@ namespace Brizco.Domain.Dtos.SmallDtos; public class ShiftPlanUserSDto : BaseDto { public Guid ShiftPlanId { get; set; } - public Guid ApplicationUserId { get; set; } + public Guid UserId { get; set; } + public Guid PositionId { get; set; } } \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs b/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs index c0bf67e..96d5042 100644 --- a/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs @@ -6,11 +6,14 @@ public class TaskSDto : BaseDto public string Title { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public bool IsDisposable { get; set; } - public DateTime SetFor { get; set; } + public long SetFor { get; set; } public bool HasDisposed { get; set; } public Guid ComplexId { get; set; } public TaskScheduleType ScheduleType { get; set; } + public List Shifts { get; set; } = new(); + public List Routines { get; set; } = new(); + public List Positions { get; set; } = new(); public int Amount { get; set; } public PurchaseAmountType AmountType { get; set; } diff --git a/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs b/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs index 7d512ba..09ae82e 100644 --- a/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs +++ b/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs @@ -50,19 +50,5 @@ public partial class Position { return new Position(name, description, complexId, sectionId); } - - public PositionUser AddUser(Guid userId , Guid shiftPlanId) - { - var positionUser = PositionUser.Create(this.Id, userId, shiftPlanId); - this.Users.Add(positionUser); - return positionUser; - } } -public partial class PositionUser -{ - public static PositionUser Create(Guid positionId, Guid userId, Guid shiftPlanId) - { - return new PositionUser(positionId, userId, shiftPlanId); - } -} diff --git a/Brizco.Domain/Entities/Complex/Position.cs b/Brizco.Domain/Entities/Complex/Position.cs index fdd8998..8398392 100644 --- a/Brizco.Domain/Entities/Complex/Position.cs +++ b/Brizco.Domain/Entities/Complex/Position.cs @@ -24,6 +24,4 @@ public partial class Position : ApiEntity public Guid SectionId { get; set; } public Section? Section { get; set; } - - public List Users { get; internal set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Complex/PositionUser.cs b/Brizco.Domain/Entities/Complex/PositionUser.cs deleted file mode 100644 index 0ff135f..0000000 --- a/Brizco.Domain/Entities/Complex/PositionUser.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Brizco.Domain.Entities.User; - -namespace Brizco.Domain.Entities.Complex; -[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] -[GenerateMapper] -public partial class PositionUser : ApiEntity -{ - public PositionUser() - { - - } - public PositionUser(Guid positionId,Guid applicationUserId ,Guid shiftPlanId) - { - ApplicationUserId = applicationUserId; - ShiftPlanId = shiftPlanId; - PositionId = positionId; - } - - public Guid ApplicationUserId { get; set; } - public ApplicationUser? ApplicationUser { get; set; } - - public Guid PositionId { get; set; } - public Position? Position { get; set; } - - public Guid ShiftPlanId { get; set; } - public ShiftPlan? ShiftPlan { get; set; } -} \ 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 c3997a5..562e9ca 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) + public ShiftPlan AddPlan(DateTime planDate,Guid routineId) { - var plan = new ShiftPlan(planDate , Id); + var plan = new ShiftPlan(planDate , routineId, Id); Plans.Add(plan); return plan; } @@ -31,9 +31,9 @@ public partial class Shift public partial class ShiftPlan { - public ShiftPlanUser AddUser(Guid userId) + public ShiftPlanUser AddUser(Guid positionId,Guid userId) { - var planUser = new ShiftPlanUser(Id , userId); + var planUser = new ShiftPlanUser(Id , positionId, userId); Users.Add(planUser); return planUser; } diff --git a/Brizco.Domain/Entities/Shift/ShiftPlan.cs b/Brizco.Domain/Entities/Shift/ShiftPlan.cs index 21f6c53..308e1d4 100644 --- a/Brizco.Domain/Entities/Shift/ShiftPlan.cs +++ b/Brizco.Domain/Entities/Shift/ShiftPlan.cs @@ -10,15 +10,19 @@ public partial class ShiftPlan : ApiEntity } - internal ShiftPlan(DateTime planDate,Guid shiftId) + internal ShiftPlan(DateTime planFor, Guid routineId,Guid shiftId) { - PlanDate = planDate; + PlanFor = planFor; + RoutineId = routineId; ShiftId = shiftId; } - public DateTime PlanDate { get; internal set; } + public DateTime PlanFor { get; internal set; } public Guid ShiftId { get; internal set; } public virtual Shift? Shift { get; internal set; } + public Guid RoutineId { get; internal set; } + public virtual Routine.Routine? Routine { get; internal set; } + public List Users { get; internal set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Shift/ShiftPlanUser.cs b/Brizco.Domain/Entities/Shift/ShiftPlanUser.cs index 0ef78b0..8382f30 100644 --- a/Brizco.Domain/Entities/Shift/ShiftPlanUser.cs +++ b/Brizco.Domain/Entities/Shift/ShiftPlanUser.cs @@ -11,14 +11,18 @@ public class ShiftPlanUser : ApiEntity } - public ShiftPlanUser(Guid shiftPlanId, Guid applicationUserId) + public ShiftPlanUser(Guid shiftPlanId,Guid positionId, Guid userId) { ShiftPlanId = shiftPlanId; - ApplicationUserId = applicationUserId; + PositionId = positionId; + UserId = userId; } public Guid ShiftPlanId { get; internal set; } public ShiftPlan? ShiftPlan { get; internal set; } - public Guid ApplicationUserId { get; internal set; } - public ApplicationUser? ApplicationUser { get; internal set; } + public Guid PositionId { get; internal set; } + public Position? Position { get; internal set; } + + public Guid UserId { get; internal set; } + public ApplicationUser? User { get; internal set; } } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Task/TaskPosition.cs b/Brizco.Domain/Entities/Task/TaskPosition.cs index 73edae2..89f7043 100644 --- a/Brizco.Domain/Entities/Task/TaskPosition.cs +++ b/Brizco.Domain/Entities/Task/TaskPosition.cs @@ -17,7 +17,7 @@ public class TaskPosition : ApiEntity TaskId = taskId; } public Guid PositionId { get; internal set; } - public virtual Position? Role { get; internal set; } + public virtual Position? Position { get; internal set; } public Guid TaskId { get; internal set; } public virtual Task? Task { get; internal set; } diff --git a/Brizco.Domain/Mappers/PositionMapper.g.cs b/Brizco.Domain/Mappers/PositionMapper.g.cs index 1dffcbf..2e97e7c 100644 --- a/Brizco.Domain/Mappers/PositionMapper.g.cs +++ b/Brizco.Domain/Mappers/PositionMapper.g.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; using Brizco.Domain.Dtos.LargDtos; using Brizco.Domain.Dtos.SmallDtos; @@ -95,215 +93,95 @@ namespace Brizco.Domain.Mappers Name = p9.SectionName, Id = p9.SectionId }, - Users = funcMain1(p9.Users), Id = p9.Id }; } - public static Position AdaptTo(this PositionLDto p11, Position p12) - { - if (p11 == null) - { - return null; - } - Position result = p12 ?? new Position(); - - result.Name = p11.Name; - result.Description = p11.Description; - result.ComplexId = p11.ComplexId; - result.Complex = funcMain2(new Never(), result.Complex, p11); - result.SectionId = p11.SectionId; - result.Section = funcMain3(new Never(), result.Section, p11); - result.Users = funcMain4(p11.Users, result.Users); - result.Id = p11.Id; - return result; - - } - public static Expression> ProjectLDtoToPosition => p19 => new Position() - { - Name = p19.Name, - Description = p19.Description, - ComplexId = p19.ComplexId, - Complex = new Complex() {Id = p19.ComplexId}, - SectionId = p19.SectionId, - Section = new Section() - { - Name = p19.SectionName, - Id = p19.SectionId - }, - Users = p19.Users.Select(p20 => new PositionUser() - { - ApplicationUserId = p20.ApplicationUserId, - PositionId = p20.PositionId, - Id = p20.Id - }).ToList(), - Id = p19.Id - }; - public static PositionLDto AdaptToLDto(this Position p21) - { - return p21 == null ? null : new PositionLDto() - { - Name = p21.Name, - Description = p21.Description, - ComplexId = p21.ComplexId, - SectionId = p21.SectionId, - SectionName = p21.Section != null ? p21.Section.Name : string.Empty, - Users = funcMain5(p21.Users), - Id = p21.Id - }; - } - public static PositionLDto AdaptTo(this Position p23, PositionLDto p24) - { - if (p23 == null) - { - return null; - } - PositionLDto result = p24 ?? new PositionLDto(); - - result.Name = p23.Name; - result.Description = p23.Description; - result.ComplexId = p23.ComplexId; - result.SectionId = p23.SectionId; - result.SectionName = p23.Section != null ? p23.Section.Name : string.Empty; - result.Users = funcMain6(p23.Users, result.Users); - result.Id = p23.Id; - return result; - - } - public static Expression> ProjectToLDto => p27 => new PositionLDto() - { - Name = p27.Name, - Description = p27.Description, - ComplexId = p27.ComplexId, - SectionId = p27.SectionId, - SectionName = p27.Section != null ? p27.Section.Name : string.Empty, - Users = p27.Users.Select(p28 => new PositionUserSDto() - { - ApplicationUserId = p28.ApplicationUserId, - PositionId = p28.PositionId, - Id = p28.Id - }).ToList(), - Id = p27.Id - }; - - private static List funcMain1(List p10) + public static Position AdaptTo(this PositionLDto p10, Position p11) { if (p10 == null) { return null; } - List result = new List(p10.Count); + Position result = p11 ?? new Position(); - int i = 0; - int len = p10.Count; + result.Name = p10.Name; + result.Description = p10.Description; + result.ComplexId = p10.ComplexId; + result.Complex = funcMain1(new Never(), result.Complex, p10); + result.SectionId = p10.SectionId; + result.Section = funcMain2(new Never(), result.Section, p10); + result.Id = p10.Id; + return result; - while (i < len) + } + public static Expression> ProjectLDtoToPosition => p16 => new Position() + { + Name = p16.Name, + Description = p16.Description, + ComplexId = p16.ComplexId, + Complex = new Complex() {Id = p16.ComplexId}, + SectionId = p16.SectionId, + Section = new Section() { - PositionUserSDto item = p10[i]; - result.Add(item == null ? null : new PositionUser() - { - ApplicationUserId = item.ApplicationUserId, - PositionId = item.PositionId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static Complex funcMain2(Never p13, Complex p14, PositionLDto p11) + Name = p16.SectionName, + Id = p16.SectionId + }, + Id = p16.Id + }; + public static PositionLDto AdaptToLDto(this Position p17) { - Complex result = p14 ?? new Complex(); - - result.Id = p11.ComplexId; - return result; - + return p17 == null ? null : new PositionLDto() + { + Name = p17.Name, + Description = p17.Description, + ComplexId = p17.ComplexId, + SectionId = p17.SectionId, + SectionName = p17.Section != null ? p17.Section.Name : string.Empty, + Id = p17.Id + }; } - - private static Section funcMain3(Never p15, Section p16, PositionLDto p11) + public static PositionLDto AdaptTo(this Position p18, PositionLDto p19) { - Section result = p16 ?? new Section(); - - result.Name = p11.SectionName; - result.Id = p11.SectionId; - return result; - - } - - private static List funcMain4(List p17, List p18) - { - if (p17 == null) + if (p18 == null) { return null; } - List result = new List(p17.Count); + PositionLDto result = p19 ?? new PositionLDto(); - int i = 0; - int len = p17.Count; + result.Name = p18.Name; + result.Description = p18.Description; + result.ComplexId = p18.ComplexId; + result.SectionId = p18.SectionId; + result.SectionName = p18.Section != null ? p18.Section.Name : string.Empty; + result.Id = p18.Id; + return result; - while (i < len) - { - PositionUserSDto item = p17[i]; - result.Add(item == null ? null : new PositionUser() - { - ApplicationUserId = item.ApplicationUserId, - PositionId = item.PositionId, - Id = item.Id - }); - i++; - } + } + public static Expression> ProjectToLDto => p20 => new PositionLDto() + { + Name = p20.Name, + Description = p20.Description, + ComplexId = p20.ComplexId, + SectionId = p20.SectionId, + SectionName = p20.Section != null ? p20.Section.Name : string.Empty, + Id = p20.Id + }; + + private static Complex funcMain1(Never p12, Complex p13, PositionLDto p10) + { + Complex result = p13 ?? new Complex(); + + result.Id = p10.ComplexId; return result; } - private static List funcMain5(List p22) + private static Section funcMain2(Never p14, Section p15, PositionLDto p10) { - if (p22 == null) - { - return null; - } - List result = new List(p22.Count); + Section result = p15 ?? new Section(); - int i = 0; - int len = p22.Count; - - while (i < len) - { - PositionUser item = p22[i]; - result.Add(item == null ? null : new PositionUserSDto() - { - ApplicationUserId = item.ApplicationUserId, - PositionId = item.PositionId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain6(List p25, List p26) - { - if (p25 == null) - { - return null; - } - List result = new List(p25.Count); - - int i = 0; - int len = p25.Count; - - while (i < len) - { - PositionUser item = p25[i]; - result.Add(item == null ? null : new PositionUserSDto() - { - ApplicationUserId = item.ApplicationUserId, - PositionId = item.PositionId, - Id = item.Id - }); - i++; - } + result.Name = p10.SectionName; + result.Id = p10.SectionId; return result; } diff --git a/Brizco.Domain/Mappers/PositionUserMapper.g.cs b/Brizco.Domain/Mappers/PositionUserMapper.g.cs deleted file mode 100644 index 9e54d73..0000000 --- a/Brizco.Domain/Mappers/PositionUserMapper.g.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Linq.Expressions; -using Brizco.Domain.Dtos.SmallDtos; -using Brizco.Domain.Entities.Complex; - -namespace Brizco.Domain.Mappers -{ - public static partial class PositionUserMapper - { - public static PositionUser AdaptToPositionUser(this PositionUserSDto p1) - { - return p1 == null ? null : new PositionUser() - { - ApplicationUserId = p1.ApplicationUserId, - PositionId = p1.PositionId, - Id = p1.Id - }; - } - public static PositionUser AdaptTo(this PositionUserSDto p2, PositionUser p3) - { - if (p2 == null) - { - return null; - } - PositionUser result = p3 ?? new PositionUser(); - - result.ApplicationUserId = p2.ApplicationUserId; - result.PositionId = p2.PositionId; - result.Id = p2.Id; - return result; - - } - public static Expression> ProjectToPositionUser => p4 => new PositionUser() - { - ApplicationUserId = p4.ApplicationUserId, - PositionId = p4.PositionId, - Id = p4.Id - }; - public static PositionUserSDto AdaptToSDto(this PositionUser p5) - { - return p5 == null ? null : new PositionUserSDto() - { - ApplicationUserId = p5.ApplicationUserId, - PositionId = p5.PositionId, - Id = p5.Id - }; - } - public static PositionUserSDto AdaptTo(this PositionUser p6, PositionUserSDto p7) - { - if (p6 == null) - { - return null; - } - PositionUserSDto result = p7 ?? new PositionUserSDto(); - - result.ApplicationUserId = p6.ApplicationUserId; - result.PositionId = p6.PositionId; - result.Id = p6.Id; - return result; - - } - public static Expression> ProjectToSDto => p8 => new PositionUserSDto() - { - ApplicationUserId = p8.ApplicationUserId, - PositionId = p8.PositionId, - Id = p8.Id - }; - } -} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs index bd092ec..509bd40 100644 --- a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs @@ -94,7 +94,8 @@ namespace Brizco.Domain.Mappers Users = p15.Users.Select(p16 => new ShiftPlanUser() { ShiftPlanId = p16.ShiftPlanId, - ApplicationUserId = p16.ApplicationUserId, + PositionId = p16.PositionId, + UserId = p16.UserId, Id = p16.Id }).ToList(), Id = p15.Id @@ -128,7 +129,8 @@ namespace Brizco.Domain.Mappers Users = p23.Users.Select(p24 => new ShiftPlanUserSDto() { ShiftPlanId = p24.ShiftPlanId, - ApplicationUserId = p24.ApplicationUserId, + UserId = p24.UserId, + PositionId = p24.PositionId, Id = p24.Id }).ToList(), Id = p23.Id @@ -151,7 +153,8 @@ namespace Brizco.Domain.Mappers result.Add(item == null ? null : new ShiftPlanUser() { ShiftPlanId = item.ShiftPlanId, - ApplicationUserId = item.ApplicationUserId, + PositionId = item.PositionId, + UserId = item.UserId, Id = item.Id }); i++; @@ -177,7 +180,8 @@ namespace Brizco.Domain.Mappers result.Add(item == null ? null : new ShiftPlanUser() { ShiftPlanId = item.ShiftPlanId, - ApplicationUserId = item.ApplicationUserId, + PositionId = item.PositionId, + UserId = item.UserId, Id = item.Id }); i++; @@ -203,7 +207,8 @@ namespace Brizco.Domain.Mappers result.Add(item == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = item.ShiftPlanId, - ApplicationUserId = item.ApplicationUserId, + UserId = item.UserId, + PositionId = item.PositionId, Id = item.Id }); i++; @@ -229,7 +234,8 @@ namespace Brizco.Domain.Mappers result.Add(item == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = item.ShiftPlanId, - ApplicationUserId = item.ApplicationUserId, + UserId = item.UserId, + PositionId = item.PositionId, Id = item.Id }); i++; diff --git a/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs index 1b45ad6..b29219a 100644 --- a/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs @@ -12,7 +12,8 @@ namespace Brizco.Domain.Mappers return p1 == null ? null : new ShiftPlanUser() { ShiftPlanId = p1.ShiftPlanId, - ApplicationUserId = p1.ApplicationUserId, + PositionId = p1.PositionId, + UserId = p1.UserId, Id = p1.Id }; } @@ -25,7 +26,8 @@ namespace Brizco.Domain.Mappers ShiftPlanUser result = p3 ?? new ShiftPlanUser(); result.ShiftPlanId = p2.ShiftPlanId; - result.ApplicationUserId = p2.ApplicationUserId; + result.PositionId = p2.PositionId; + result.UserId = p2.UserId; result.Id = p2.Id; return result; @@ -33,7 +35,8 @@ namespace Brizco.Domain.Mappers public static Expression> ProjectToShiftPlanUser => p4 => new ShiftPlanUser() { ShiftPlanId = p4.ShiftPlanId, - ApplicationUserId = p4.ApplicationUserId, + PositionId = p4.PositionId, + UserId = p4.UserId, Id = p4.Id }; public static ShiftPlanUserSDto AdaptToSDto(this ShiftPlanUser p5) @@ -41,7 +44,8 @@ namespace Brizco.Domain.Mappers return p5 == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = p5.ShiftPlanId, - ApplicationUserId = p5.ApplicationUserId, + UserId = p5.UserId, + PositionId = p5.PositionId, Id = p5.Id }; } @@ -54,7 +58,8 @@ namespace Brizco.Domain.Mappers ShiftPlanUserSDto result = p7 ?? new ShiftPlanUserSDto(); result.ShiftPlanId = p6.ShiftPlanId; - result.ApplicationUserId = p6.ApplicationUserId; + result.UserId = p6.UserId; + result.PositionId = p6.PositionId; result.Id = p6.Id; return result; @@ -62,7 +67,8 @@ namespace Brizco.Domain.Mappers public static Expression> ProjectToSDto => p8 => new ShiftPlanUserSDto() { ShiftPlanId = p8.ShiftPlanId, - ApplicationUserId = p8.ApplicationUserId, + UserId = p8.UserId, + PositionId = p8.PositionId, Id = p8.Id }; } diff --git a/Brizco.Domain/Mappers/TaskMapper.g.cs b/Brizco.Domain/Mappers/TaskMapper.g.cs index b89d5d2..a39e3c3 100644 --- a/Brizco.Domain/Mappers/TaskMapper.g.cs +++ b/Brizco.Domain/Mappers/TaskMapper.g.cs @@ -2,9 +2,12 @@ using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using Brizco.Common.Extensions; using Brizco.Domain.Dtos.LargDtos; 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 @@ -19,345 +22,403 @@ namespace Brizco.Domain.Mappers Title = p1.Title, Description = p1.Description, IsDisposable = p1.IsDisposable, - SetFor = p1.SetFor, + SetFor = Convert.ToDateTime(p1.SetFor), HasDisposed = p1.HasDisposed, ScheduleType = p1.ScheduleType, ComplexId = p1.ComplexId, + Complex = new Complex() {Id = p1.ComplexId}, Amount = p1.Amount, AmountType = p1.AmountType, + Shifts = funcMain1(p1.Shifts), + Routines = funcMain2(p1.Routines), + Positions = funcMain3(p1.Positions), Id = p1.Id }; } - public static Task AdaptTo(this TaskSDto p2, Task p3) + public static Task AdaptTo(this TaskSDto p5, Task p6) + { + if (p5 == null) + { + return null; + } + Task result = p6 ?? new Task(); + + result.Type = p5.Type; + result.Title = p5.Title; + result.Description = p5.Description; + result.IsDisposable = p5.IsDisposable; + result.SetFor = Convert.ToDateTime(p5.SetFor); + result.HasDisposed = p5.HasDisposed; + result.ScheduleType = p5.ScheduleType; + result.ComplexId = p5.ComplexId; + result.Complex = funcMain4(new Never(), result.Complex, p5); + result.Amount = p5.Amount; + result.AmountType = p5.AmountType; + result.Shifts = funcMain5(p5.Shifts, result.Shifts); + result.Routines = funcMain6(p5.Routines, result.Routines); + result.Positions = funcMain7(p5.Positions, result.Positions); + result.Id = p5.Id; + return result; + + } + public static Expression> ProjectToTask => p15 => new Task() + { + Type = p15.Type, + Title = p15.Title, + Description = p15.Description, + IsDisposable = p15.IsDisposable, + SetFor = Convert.ToDateTime(p15.SetFor), + HasDisposed = p15.HasDisposed, + ScheduleType = p15.ScheduleType, + ComplexId = p15.ComplexId, + Complex = new Complex() {Id = p15.ComplexId}, + Amount = p15.Amount, + AmountType = p15.AmountType, + Shifts = p15.Shifts.Select(p16 => (TaskShift)Convert.ChangeType((object)p16, typeof(TaskShift))).ToList(), + Routines = p15.Routines.Select(p17 => (TaskRoutine)Convert.ChangeType((object)p17, typeof(TaskRoutine))).ToList(), + Positions = p15.Positions.Select(p18 => (TaskPosition)Convert.ChangeType((object)p18, typeof(TaskPosition))).ToList(), + Id = p15.Id + }; + public static TaskSDto AdaptToSDto(this Task p19) + { + return p19 == null ? null : new TaskSDto() + { + Type = p19.Type, + Title = p19.Title, + Description = p19.Description, + IsDisposable = p19.IsDisposable, + SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p19.SetFor), + HasDisposed = p19.HasDisposed, + ComplexId = p19.ComplexId, + ScheduleType = p19.ScheduleType, + Shifts = funcMain8(p19.Shifts.Select(funcMain9)), + Routines = funcMain10(p19.Routines.Select(funcMain11)), + Positions = funcMain12(p19.Positions.Select(funcMain13)), + Amount = p19.Amount, + AmountType = p19.AmountType, + Id = p19.Id + }; + } + public static TaskSDto AdaptTo(this Task p23, TaskSDto p24) + { + if (p23 == null) + { + return null; + } + TaskSDto result = p24 ?? new TaskSDto(); + + result.Type = p23.Type; + result.Title = p23.Title; + result.Description = p23.Description; + result.IsDisposable = p23.IsDisposable; + result.SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p23.SetFor); + result.HasDisposed = p23.HasDisposed; + result.ComplexId = p23.ComplexId; + result.ScheduleType = p23.ScheduleType; + result.Shifts = funcMain14(p23.Shifts.Select(funcMain9), result.Shifts); + result.Routines = funcMain15(p23.Routines.Select(funcMain11), result.Routines); + result.Positions = funcMain16(p23.Positions.Select(funcMain13), result.Positions); + result.Amount = p23.Amount; + result.AmountType = p23.AmountType; + result.Id = p23.Id; + return result; + + } + public static Expression> ProjectToSDto => p31 => new TaskSDto() + { + Type = p31.Type, + Title = p31.Title, + Description = p31.Description, + IsDisposable = p31.IsDisposable, + SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p31.SetFor), + HasDisposed = p31.HasDisposed, + ComplexId = p31.ComplexId, + ScheduleType = p31.ScheduleType, + Shifts = (List)p31.Shifts.Select(d => d.Shift != null ? d.Shift.Title : string.Empty), + Routines = (List)p31.Routines.Select(d => d.Routine != null ? d.Routine.Name : string.Empty), + Positions = (List)p31.Positions.Select(d => d.Position != null ? d.Position.Name : string.Empty), + Amount = p31.Amount, + AmountType = p31.AmountType, + Id = p31.Id + }; + public static Task AdaptToTask(this TaskLDto p32) + { + return p32 == null ? null : new Task() + { + Type = p32.Type, + Title = p32.Title, + Description = p32.Description, + IsDisposable = p32.IsDisposable, + SetFor = Convert.ToDateTime(p32.SetFor), + HasDisposed = p32.HasDisposed, + ScheduleType = p32.ScheduleType, + Amount = p32.Amount, + AmountType = p32.AmountType, + Shifts = funcMain17(p32.Shifts), + Days = funcMain18(p32.Days), + Routines = funcMain19(p32.Routines), + Positions = funcMain20(p32.Positions), + Id = p32.Id + }; + } + public static Task AdaptTo(this TaskLDto p37, Task p38) + { + if (p37 == null) + { + return null; + } + Task result = p38 ?? new Task(); + + result.Type = p37.Type; + result.Title = p37.Title; + result.Description = p37.Description; + result.IsDisposable = p37.IsDisposable; + result.SetFor = Convert.ToDateTime(p37.SetFor); + result.HasDisposed = p37.HasDisposed; + result.ScheduleType = p37.ScheduleType; + result.Amount = p37.Amount; + result.AmountType = p37.AmountType; + result.Shifts = funcMain21(p37.Shifts, result.Shifts); + result.Days = funcMain22(p37.Days, result.Days); + result.Routines = funcMain23(p37.Routines, result.Routines); + result.Positions = funcMain24(p37.Positions, result.Positions); + result.Id = p37.Id; + return result; + + } + public static Expression> ProjectLDtoToTask => p47 => new Task() + { + Type = p47.Type, + Title = p47.Title, + Description = p47.Description, + IsDisposable = p47.IsDisposable, + SetFor = Convert.ToDateTime(p47.SetFor), + HasDisposed = p47.HasDisposed, + ScheduleType = p47.ScheduleType, + Amount = p47.Amount, + AmountType = p47.AmountType, + Shifts = p47.Shifts.Select(p48 => new TaskShift() + { + TaskId = p48.TaskId, + ShiftId = p48.ShiftId + }).ToList(), + Days = p47.Days.Select(p49 => new TaskDay() + { + DayOfWeek = p49.DayOfWeek, + TaskId = p49.TaskId, + Id = p49.Id + }).ToList(), + Routines = p47.Routines.Select(p50 => new TaskRoutine() + { + TaskId = p50.TaskId, + RoutineId = p50.RoutineId, + Id = p50.Id + }).ToList(), + Positions = p47.Positions.Select(p51 => new TaskPosition() + { + PositionId = p51.PositionId, + TaskId = p51.TaskId, + Id = p51.Id + }).ToList(), + Id = p47.Id + }; + public static TaskLDto AdaptToLDto(this Task p52) + { + return p52 == null ? null : new TaskLDto() + { + Type = p52.Type, + Title = p52.Title, + Description = p52.Description, + IsDisposable = p52.IsDisposable, + SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p52.SetFor), + HasDisposed = p52.HasDisposed, + ScheduleType = p52.ScheduleType, + Amount = p52.Amount, + AmountType = p52.AmountType, + Shifts = funcMain25(p52.Shifts), + Positions = funcMain26(p52.Positions), + Days = funcMain27(p52.Days), + Routines = funcMain28(p52.Routines), + Id = p52.Id + }; + } + public static TaskLDto AdaptTo(this Task p57, TaskLDto p58) + { + if (p57 == null) + { + return null; + } + TaskLDto result = p58 ?? new TaskLDto(); + + result.Type = p57.Type; + result.Title = p57.Title; + result.Description = p57.Description; + result.IsDisposable = p57.IsDisposable; + result.SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p57.SetFor); + result.HasDisposed = p57.HasDisposed; + result.ScheduleType = p57.ScheduleType; + result.Amount = p57.Amount; + result.AmountType = p57.AmountType; + result.Shifts = funcMain29(p57.Shifts, result.Shifts); + result.Positions = funcMain30(p57.Positions, result.Positions); + result.Days = funcMain31(p57.Days, result.Days); + result.Routines = funcMain32(p57.Routines, result.Routines); + result.Id = p57.Id; + return result; + + } + public static Expression> ProjectToLDto => p67 => new TaskLDto() + { + Type = p67.Type, + Title = p67.Title, + Description = p67.Description, + IsDisposable = p67.IsDisposable, + SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p67.SetFor), + HasDisposed = p67.HasDisposed, + ScheduleType = p67.ScheduleType, + Amount = p67.Amount, + AmountType = p67.AmountType, + Shifts = p67.Shifts.Select(p68 => new TaskShiftSDto() + { + ShiftId = p68.ShiftId, + TaskId = p68.TaskId + }).ToList(), + Positions = p67.Positions.Select(p69 => new TaskPositionSDto() + { + PositionId = p69.PositionId, + TaskId = p69.TaskId, + Id = p69.Id + }).ToList(), + Days = p67.Days.Select(p70 => new TaskDaySDto() + { + DayOfWeek = p70.DayOfWeek, + TaskId = p70.TaskId, + Id = p70.Id + }).ToList(), + Routines = p67.Routines.Select(p71 => new TaskRoutineSDto() + { + TaskId = p71.TaskId, + RoutineId = p71.RoutineId, + Id = p71.Id + }).ToList(), + Id = p67.Id + }; + + private static List funcMain1(List p2) { if (p2 == null) { return null; } - Task result = p3 ?? new Task(); - - result.Type = p2.Type; - result.Title = p2.Title; - result.Description = p2.Description; - result.IsDisposable = p2.IsDisposable; - result.SetFor = p2.SetFor; - result.HasDisposed = p2.HasDisposed; - result.ScheduleType = p2.ScheduleType; - result.ComplexId = p2.ComplexId; - result.Amount = p2.Amount; - result.AmountType = p2.AmountType; - result.Id = p2.Id; - return result; - - } - public static Expression> ProjectToTask => p4 => new Task() - { - Type = p4.Type, - Title = p4.Title, - Description = p4.Description, - IsDisposable = p4.IsDisposable, - SetFor = p4.SetFor, - HasDisposed = p4.HasDisposed, - ScheduleType = p4.ScheduleType, - ComplexId = p4.ComplexId, - Amount = p4.Amount, - AmountType = p4.AmountType, - Id = p4.Id - }; - public static TaskSDto AdaptToSDto(this Task p5) - { - return p5 == null ? null : new TaskSDto() - { - Type = p5.Type, - Title = p5.Title, - Description = p5.Description, - IsDisposable = p5.IsDisposable, - SetFor = p5.SetFor, - HasDisposed = p5.HasDisposed, - ComplexId = p5.ComplexId, - ScheduleType = p5.ScheduleType, - Amount = p5.Amount, - AmountType = p5.AmountType, - Id = p5.Id - }; - } - public static TaskSDto AdaptTo(this Task p6, TaskSDto p7) - { - if (p6 == null) - { - return null; - } - TaskSDto result = p7 ?? new TaskSDto(); - - result.Type = p6.Type; - result.Title = p6.Title; - result.Description = p6.Description; - result.IsDisposable = p6.IsDisposable; - result.SetFor = p6.SetFor; - result.HasDisposed = p6.HasDisposed; - result.ComplexId = p6.ComplexId; - result.ScheduleType = p6.ScheduleType; - result.Amount = p6.Amount; - result.AmountType = p6.AmountType; - result.Id = p6.Id; - return result; - - } - public static Expression> ProjectToSDto => p8 => new TaskSDto() - { - Type = p8.Type, - Title = p8.Title, - Description = p8.Description, - IsDisposable = p8.IsDisposable, - SetFor = p8.SetFor, - HasDisposed = p8.HasDisposed, - ComplexId = p8.ComplexId, - ScheduleType = p8.ScheduleType, - Amount = p8.Amount, - AmountType = p8.AmountType, - Id = p8.Id - }; - public static Task AdaptToTask(this TaskLDto p9) - { - return p9 == null ? null : new Task() - { - Type = p9.Type, - Title = p9.Title, - Description = p9.Description, - IsDisposable = p9.IsDisposable, - SetFor = p9.SetFor, - HasDisposed = p9.HasDisposed, - ScheduleType = p9.ScheduleType, - Amount = p9.Amount, - AmountType = p9.AmountType, - Shifts = funcMain1(p9.Shifts), - Days = funcMain2(p9.Days), - Routines = funcMain3(p9.Routines), - Positions = funcMain4(p9.Positions), - Id = p9.Id - }; - } - public static Task AdaptTo(this TaskLDto p14, Task p15) - { - if (p14 == null) - { - return null; - } - Task result = p15 ?? new Task(); - - result.Type = p14.Type; - result.Title = p14.Title; - result.Description = p14.Description; - result.IsDisposable = p14.IsDisposable; - result.SetFor = p14.SetFor; - result.HasDisposed = p14.HasDisposed; - result.ScheduleType = p14.ScheduleType; - result.Amount = p14.Amount; - result.AmountType = p14.AmountType; - result.Shifts = funcMain5(p14.Shifts, result.Shifts); - result.Days = funcMain6(p14.Days, result.Days); - result.Routines = funcMain7(p14.Routines, result.Routines); - result.Positions = funcMain8(p14.Positions, result.Positions); - result.Id = p14.Id; - return result; - - } - public static Expression> ProjectLDtoToTask => p24 => new Task() - { - Type = p24.Type, - Title = p24.Title, - Description = p24.Description, - IsDisposable = p24.IsDisposable, - SetFor = p24.SetFor, - HasDisposed = p24.HasDisposed, - ScheduleType = p24.ScheduleType, - Amount = p24.Amount, - AmountType = p24.AmountType, - Shifts = p24.Shifts.Select(p25 => new TaskShift() - { - TaskId = p25.TaskId, - ShiftId = p25.ShiftId - }).ToList(), - Days = p24.Days.Select(p26 => new TaskDay() - { - DayOfWeek = p26.DayOfWeek, - TaskId = p26.TaskId, - Id = p26.Id - }).ToList(), - Routines = p24.Routines.Select(p27 => new TaskRoutine() - { - TaskId = p27.TaskId, - RoutineId = p27.RoutineId, - Id = p27.Id - }).ToList(), - Positions = p24.Positions.Select(p28 => new TaskPosition() - { - PositionId = p28.PositionId, - TaskId = p28.TaskId, - Id = p28.Id - }).ToList(), - Id = p24.Id - }; - public static TaskLDto AdaptToLDto(this Task p29) - { - return p29 == null ? null : new TaskLDto() - { - Type = p29.Type, - Title = p29.Title, - Description = p29.Description, - IsDisposable = p29.IsDisposable, - SetFor = p29.SetFor, - HasDisposed = p29.HasDisposed, - ScheduleType = p29.ScheduleType, - Amount = p29.Amount, - AmountType = p29.AmountType, - Shifts = funcMain9(p29.Shifts), - Positions = funcMain10(p29.Positions), - Days = funcMain11(p29.Days), - Routines = funcMain12(p29.Routines), - Id = p29.Id - }; - } - public static TaskLDto AdaptTo(this Task p34, TaskLDto p35) - { - if (p34 == null) - { - return null; - } - TaskLDto result = p35 ?? new TaskLDto(); - - result.Type = p34.Type; - result.Title = p34.Title; - result.Description = p34.Description; - result.IsDisposable = p34.IsDisposable; - result.SetFor = p34.SetFor; - result.HasDisposed = p34.HasDisposed; - result.ScheduleType = p34.ScheduleType; - result.Amount = p34.Amount; - result.AmountType = p34.AmountType; - result.Shifts = funcMain13(p34.Shifts, result.Shifts); - result.Positions = funcMain14(p34.Positions, result.Positions); - result.Days = funcMain15(p34.Days, result.Days); - result.Routines = funcMain16(p34.Routines, result.Routines); - result.Id = p34.Id; - return result; - - } - public static Expression> ProjectToLDto => p44 => new TaskLDto() - { - Type = p44.Type, - Title = p44.Title, - Description = p44.Description, - IsDisposable = p44.IsDisposable, - SetFor = p44.SetFor, - HasDisposed = p44.HasDisposed, - ScheduleType = p44.ScheduleType, - Amount = p44.Amount, - AmountType = p44.AmountType, - Shifts = p44.Shifts.Select(p45 => new TaskShiftSDto() - { - ShiftId = p45.ShiftId, - TaskId = p45.TaskId - }).ToList(), - Positions = p44.Positions.Select(p46 => new TaskPositionSDto() - { - PositionId = p46.PositionId, - TaskId = p46.TaskId, - Id = p46.Id - }).ToList(), - Days = p44.Days.Select(p47 => new TaskDaySDto() - { - DayOfWeek = p47.DayOfWeek, - TaskId = p47.TaskId, - Id = p47.Id - }).ToList(), - Routines = p44.Routines.Select(p48 => new TaskRoutineSDto() - { - TaskId = p48.TaskId, - RoutineId = p48.RoutineId, - Id = p48.Id - }).ToList(), - Id = p44.Id - }; - - private static List funcMain1(List p10) - { - if (p10 == null) - { - return null; - } - List result = new List(p10.Count); + List result = new List(p2.Count); int i = 0; - int len = p10.Count; + int len = p2.Count; while (i < len) { - TaskShiftSDto item = p10[i]; - result.Add(item == null ? null : new TaskShift() - { - TaskId = item.TaskId, - ShiftId = item.ShiftId - }); + string item = p2[i]; + result.Add(item == null ? null : (TaskShift)Convert.ChangeType((object)item, typeof(TaskShift))); i++; } return result; } - private static List funcMain2(List p11) + private static List funcMain2(List p3) + { + if (p3 == null) + { + return null; + } + List result = new List(p3.Count); + + int i = 0; + int len = p3.Count; + + while (i < len) + { + string item = p3[i]; + result.Add(item == null ? null : (TaskRoutine)Convert.ChangeType((object)item, typeof(TaskRoutine))); + i++; + } + return result; + + } + + private static List funcMain3(List p4) + { + if (p4 == null) + { + return null; + } + List result = new List(p4.Count); + + int i = 0; + int len = p4.Count; + + while (i < len) + { + string item = p4[i]; + result.Add(item == null ? null : (TaskPosition)Convert.ChangeType((object)item, typeof(TaskPosition))); + i++; + } + return result; + + } + + private static Complex funcMain4(Never p7, Complex p8, TaskSDto p5) + { + Complex result = p8 ?? new Complex(); + + result.Id = p5.ComplexId; + return result; + + } + + private static List funcMain5(List p9, List p10) + { + if (p9 == null) + { + return null; + } + List result = new List(p9.Count); + + int i = 0; + int len = p9.Count; + + while (i < len) + { + string item = p9[i]; + result.Add(item == null ? null : (TaskShift)Convert.ChangeType((object)item, typeof(TaskShift))); + i++; + } + return result; + + } + + private static List funcMain6(List p11, List p12) { if (p11 == null) { return null; } - List result = new List(p11.Count); + List result = new List(p11.Count); int i = 0; int len = p11.Count; while (i < len) { - TaskDaySDto item = p11[i]; - result.Add(item == null ? null : new TaskDay() - { - DayOfWeek = item.DayOfWeek, - TaskId = item.TaskId, - Id = item.Id - }); + string item = p11[i]; + result.Add(item == null ? null : (TaskRoutine)Convert.ChangeType((object)item, typeof(TaskRoutine))); i++; } return result; } - private static List funcMain3(List p12) - { - if (p12 == null) - { - return null; - } - List result = new List(p12.Count); - - int i = 0; - int len = p12.Count; - - while (i < len) - { - TaskRoutineSDto item = p12[i]; - result.Add(item == null ? null : new TaskRoutine() - { - TaskId = item.TaskId, - RoutineId = item.RoutineId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain4(List p13) + private static List funcMain7(List p13, List p14) { if (p13 == null) { @@ -370,33 +431,157 @@ namespace Brizco.Domain.Mappers while (i < len) { - TaskPositionSDto item = p13[i]; - result.Add(item == null ? null : new TaskPosition() - { - PositionId = item.PositionId, - TaskId = item.TaskId, - Id = item.Id - }); + string item = p13[i]; + result.Add(item == null ? null : (TaskPosition)Convert.ChangeType((object)item, typeof(TaskPosition))); i++; } return result; } - private static List funcMain5(List p16, List p17) + private static List funcMain8(IEnumerable p20) { - if (p16 == null) + if (p20 == null) { return null; } - List result = new List(p16.Count); + List result = new List(); + + IEnumerator enumerator = p20.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } + return result; + + } + + private static string funcMain9(TaskShift d) + { + return d.Shift != null ? d.Shift.Title : string.Empty; + } + + private static List funcMain10(IEnumerable p21) + { + if (p21 == null) + { + return null; + } + List result = new List(); + + IEnumerator enumerator = p21.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } + return result; + + } + + private static string funcMain11(TaskRoutine d) + { + return d.Routine != null ? d.Routine.Name : string.Empty; + } + + private static List funcMain12(IEnumerable p22) + { + if (p22 == null) + { + return null; + } + List result = new List(); + + IEnumerator enumerator = p22.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } + return result; + + } + + private static string funcMain13(TaskPosition d) + { + return d.Position != null ? d.Position.Name : string.Empty; + } + + private static List funcMain14(IEnumerable p25, List p26) + { + if (p25 == null) + { + return null; + } + List result = new List(); + + IEnumerator enumerator = p25.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } + return result; + + } + + private static List funcMain15(IEnumerable p27, List p28) + { + if (p27 == null) + { + return null; + } + List result = new List(); + + IEnumerator enumerator = p27.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } + return result; + + } + + private static List funcMain16(IEnumerable p29, List p30) + { + if (p29 == null) + { + return null; + } + List result = new List(); + + IEnumerator enumerator = p29.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } + return result; + + } + + private static List funcMain17(List p33) + { + if (p33 == null) + { + return null; + } + List result = new List(p33.Count); int i = 0; - int len = p16.Count; + int len = p33.Count; while (i < len) { - TaskShiftSDto item = p16[i]; + TaskShiftSDto item = p33[i]; result.Add(item == null ? null : new TaskShift() { TaskId = item.TaskId, @@ -408,20 +593,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain6(List p18, List p19) + private static List funcMain18(List p34) { - if (p18 == null) + if (p34 == null) { return null; } - List result = new List(p18.Count); + List result = new List(p34.Count); int i = 0; - int len = p18.Count; + int len = p34.Count; while (i < len) { - TaskDaySDto item = p18[i]; + TaskDaySDto item = p34[i]; result.Add(item == null ? null : new TaskDay() { DayOfWeek = item.DayOfWeek, @@ -434,20 +619,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain7(List p20, List p21) + private static List funcMain19(List p35) { - if (p20 == null) + if (p35 == null) { return null; } - List result = new List(p20.Count); + List result = new List(p35.Count); int i = 0; - int len = p20.Count; + int len = p35.Count; while (i < len) { - TaskRoutineSDto item = p20[i]; + TaskRoutineSDto item = p35[i]; result.Add(item == null ? null : new TaskRoutine() { TaskId = item.TaskId, @@ -460,20 +645,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain8(List p22, List p23) + private static List funcMain20(List p36) { - if (p22 == null) + if (p36 == null) { return null; } - List result = new List(p22.Count); + List result = new List(p36.Count); int i = 0; - int len = p22.Count; + int len = p36.Count; while (i < len) { - TaskPositionSDto item = p22[i]; + TaskPositionSDto item = p36[i]; result.Add(item == null ? null : new TaskPosition() { PositionId = item.PositionId, @@ -486,20 +671,123 @@ namespace Brizco.Domain.Mappers } - private static List funcMain9(List p30) + private static List funcMain21(List p39, List p40) { - if (p30 == null) + if (p39 == null) { return null; } - List result = new List(p30.Count); + List result = new List(p39.Count); int i = 0; - int len = p30.Count; + int len = p39.Count; while (i < len) { - TaskShift item = p30[i]; + TaskShiftSDto item = p39[i]; + result.Add(item == null ? null : new TaskShift() + { + TaskId = item.TaskId, + ShiftId = item.ShiftId + }); + i++; + } + return result; + + } + + private static List funcMain22(List p41, List p42) + { + if (p41 == null) + { + return null; + } + List result = new List(p41.Count); + + int i = 0; + int len = p41.Count; + + while (i < len) + { + TaskDaySDto item = p41[i]; + result.Add(item == null ? null : new TaskDay() + { + DayOfWeek = item.DayOfWeek, + TaskId = item.TaskId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain23(List p43, List p44) + { + if (p43 == null) + { + return null; + } + List result = new List(p43.Count); + + int i = 0; + int len = p43.Count; + + while (i < len) + { + TaskRoutineSDto item = p43[i]; + result.Add(item == null ? null : new TaskRoutine() + { + TaskId = item.TaskId, + RoutineId = item.RoutineId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain24(List p45, List p46) + { + if (p45 == null) + { + return null; + } + List result = new List(p45.Count); + + int i = 0; + int len = p45.Count; + + while (i < len) + { + TaskPositionSDto item = p45[i]; + result.Add(item == null ? null : new TaskPosition() + { + PositionId = item.PositionId, + TaskId = item.TaskId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain25(List p53) + { + if (p53 == null) + { + return null; + } + List result = new List(p53.Count); + + int i = 0; + int len = p53.Count; + + while (i < len) + { + TaskShift item = p53[i]; result.Add(item == null ? null : new TaskShiftSDto() { ShiftId = item.ShiftId, @@ -511,20 +799,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain10(List p31) + private static List funcMain26(List p54) { - if (p31 == null) + if (p54 == null) { return null; } - List result = new List(p31.Count); + List result = new List(p54.Count); int i = 0; - int len = p31.Count; + int len = p54.Count; while (i < len) { - TaskPosition item = p31[i]; + TaskPosition item = p54[i]; result.Add(item == null ? null : new TaskPositionSDto() { PositionId = item.PositionId, @@ -537,20 +825,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain11(List p32) + private static List funcMain27(List p55) { - if (p32 == null) + if (p55 == null) { return null; } - List result = new List(p32.Count); + List result = new List(p55.Count); int i = 0; - int len = p32.Count; + int len = p55.Count; while (i < len) { - TaskDay item = p32[i]; + TaskDay item = p55[i]; result.Add(item == null ? null : new TaskDaySDto() { DayOfWeek = item.DayOfWeek, @@ -563,20 +851,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain12(List p33) + private static List funcMain28(List p56) { - if (p33 == null) + if (p56 == null) { return null; } - List result = new List(p33.Count); + List result = new List(p56.Count); int i = 0; - int len = p33.Count; + int len = p56.Count; while (i < len) { - TaskRoutine item = p33[i]; + TaskRoutine item = p56[i]; result.Add(item == null ? null : new TaskRoutineSDto() { TaskId = item.TaskId, @@ -589,20 +877,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain13(List p36, List p37) + private static List funcMain29(List p59, List p60) { - if (p36 == null) + if (p59 == null) { return null; } - List result = new List(p36.Count); + List result = new List(p59.Count); int i = 0; - int len = p36.Count; + int len = p59.Count; while (i < len) { - TaskShift item = p36[i]; + TaskShift item = p59[i]; result.Add(item == null ? null : new TaskShiftSDto() { ShiftId = item.ShiftId, @@ -614,20 +902,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain14(List p38, List p39) + private static List funcMain30(List p61, List p62) { - if (p38 == null) + if (p61 == null) { return null; } - List result = new List(p38.Count); + List result = new List(p61.Count); int i = 0; - int len = p38.Count; + int len = p61.Count; while (i < len) { - TaskPosition item = p38[i]; + TaskPosition item = p61[i]; result.Add(item == null ? null : new TaskPositionSDto() { PositionId = item.PositionId, @@ -640,20 +928,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain15(List p40, List p41) + private static List funcMain31(List p63, List p64) { - if (p40 == null) + if (p63 == null) { return null; } - List result = new List(p40.Count); + List result = new List(p63.Count); int i = 0; - int len = p40.Count; + int len = p63.Count; while (i < len) { - TaskDay item = p40[i]; + TaskDay item = p63[i]; result.Add(item == null ? null : new TaskDaySDto() { DayOfWeek = item.DayOfWeek, @@ -666,20 +954,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain16(List p42, List p43) + private static List funcMain32(List p65, List p66) { - if (p42 == null) + if (p65 == null) { return null; } - List result = new List(p42.Count); + List result = new List(p65.Count); int i = 0; - int len = p42.Count; + int len = p65.Count; while (i < len) { - TaskRoutine item = p42[i]; + TaskRoutine item = p65[i]; result.Add(item == null ? null : new TaskRoutineSDto() { TaskId = item.TaskId, diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs index ba85234..c5c3329 100644 --- a/Brizco.Domain/MapsterRegister.cs +++ b/Brizco.Domain/MapsterRegister.cs @@ -1,6 +1,7 @@ using Brizco.Domain.Entities.Complex; using Brizco.Domain.Entities.Shift; using Mapster; +using Task = Brizco.Domain.Entities.Task.Task; namespace Brizco.Domain; @@ -8,6 +9,18 @@ public class MapsterRegister : IRegister { public void Register(TypeAdapterConfig config) { + config.NewConfig() + .Map("SetFor",o=>DateTimeExtensions.DateTimeToUnixTimeStamp(o.SetFor)) + .Map("Shifts", o => o.Shifts.Select(d => d.Shift != null ? d.Shift.Title : string.Empty)) + .Map("Routines", o => o.Routines.Select(d => d.Routine != null ? d.Routine.Name : string.Empty)) + .Map("Positions", o => o.Positions.Select(d => d.Position != null ? d.Position.Name : string.Empty)) + .TwoWays(); + + + config.NewConfig() + .Map("SetFor", o => DateTimeExtensions.DateTimeToUnixTimeStamp(o.SetFor)) + .TwoWays(); + config.NewConfig() .Map("Days",o=>o.Days.Select(d=>d.DayOfWeek).ToList()) .TwoWays(); diff --git a/Brizco.Repository/Brizco.Repository.csproj b/Brizco.Repository/Brizco.Repository.csproj index d9c19b5..06984b0 100644 --- a/Brizco.Repository/Brizco.Repository.csproj +++ b/Brizco.Repository/Brizco.Repository.csproj @@ -43,6 +43,7 @@ + diff --git a/Brizco.Repository/Handlers/Position/CreatePositionUserCommandHandler.cs b/Brizco.Repository/Handlers/Position/CreatePositionUserCommandHandler.cs deleted file mode 100644 index 767de16..0000000 --- a/Brizco.Repository/Handlers/Position/CreatePositionUserCommandHandler.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Brizco.Repository.Abstracts; - -namespace Brizco.Repository.Handlers.Position; - -public class CreatePositionUserCommandHandler : IRequestHandler -{ - private readonly IRepositoryWrapper _repositoryWrapper; - - public CreatePositionUserCommandHandler(IRepositoryWrapper repositoryWrapper) - { - _repositoryWrapper = repositoryWrapper; - } - public async Task Handle(CreatePositionUserCommand request, CancellationToken cancellationToken) - { - try - { - await _repositoryWrapper.BeginTransaction(cancellationToken); - - - - var entity = await _repositoryWrapper.SetRepository().TableNoTracking - .FirstOrDefaultAsync(p => p.Id == request.PositionId, cancellationToken); - if (entity == null) - throw new AppException("Position not found"); - entity.AddUser(request.UserId,request.ShiftPlanId); - _repositoryWrapper.SetRepository().Update(entity); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); - await _repositoryWrapper.CommitAsync(cancellationToken); - return true; - } - catch (Exception) - { - await _repositoryWrapper.RollBackAsync(cancellationToken); - throw; - } - } -} \ No newline at end of file diff --git a/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs b/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs index 22c4908..41c3f9e 100644 --- a/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs +++ b/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs @@ -29,27 +29,6 @@ public class UpdatePositionCommandHandler : IRequestHandler().TableNoTracking - .Where(pu => pu.PositionId == newPosition.Id) - .ToListAsync(cancellationToken); - - //foreach (var user in users) - //{ - // if (!request.UserIds.Contains(user.ApplicationUserId)) - // { - // _repositoryWrapper.SetRepository() - // .Delete(user); - // await _repositoryWrapper.SaveChangesAsync(cancellationToken); - // } - //} - //foreach (var userId in request.UserIds) - //{ - // if (users.FirstOrDefault(u => u.ApplicationUserId == userId) == null) - // { - // newPosition.AddUser(userId); - // } - //} - _repositoryWrapper.SetRepository() .Update(newPosition); diff --git a/Brizco.Repository/Handlers/Position/UpdatePositionUserCommandHandler.cs b/Brizco.Repository/Handlers/Position/UpdatePositionUserCommandHandler.cs deleted file mode 100644 index ad69121..0000000 --- a/Brizco.Repository/Handlers/Position/UpdatePositionUserCommandHandler.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Brizco.Repository.Abstracts; - -namespace Brizco.Repository.Handlers.Position; - -public class UpdatePositionUserCommandHandler : IRequestHandler -{ - private readonly IRepositoryWrapper _repositoryWrapper; - - public UpdatePositionUserCommandHandler(IRepositoryWrapper repositoryWrapper) - { - _repositoryWrapper = repositoryWrapper; - } - public async Task Handle(UpdatePositionUserCommand request, CancellationToken cancellationToken) - { - try - { - await _repositoryWrapper.BeginTransaction(cancellationToken); - - var entity = await _repositoryWrapper.SetRepository().TableNoTracking - .FirstOrDefaultAsync(p => p.ApplicationUserId == request.UserId , cancellationToken); - if (entity == null) - throw new AppException("PositionUser not found"); - var newEntity = PositionUser.Create(request.PositionId, request.UserId, request.ShiftPlanId); - newEntity.Id = entity.Id; - - _repositoryWrapper.SetRepository().Update(newEntity); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); - await _repositoryWrapper.CommitAsync(cancellationToken); - return true; - } - catch (Exception) - { - await _repositoryWrapper.RollBackAsync(cancellationToken); - throw; - } - } -} \ No newline at end of file diff --git a/Brizco.Repository/Handlers/Routine/CreateRoutineCommandHandler.cs b/Brizco.Repository/Handlers/Routine/CreateRoutineCommandHandler.cs index f70242d..44f362f 100644 --- a/Brizco.Repository/Handlers/Routine/CreateRoutineCommandHandler.cs +++ b/Brizco.Repository/Handlers/Routine/CreateRoutineCommandHandler.cs @@ -22,7 +22,7 @@ public class CreateRoutineCommandHandler : IRequestHandler().Add(entity); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Routine/GetRoutineShiftsQueryHandler.cs b/Brizco.Repository/Handlers/Routine/GetRoutineShiftsQueryHandler.cs new file mode 100644 index 0000000..6162c6f --- /dev/null +++ b/Brizco.Repository/Handlers/Routine/GetRoutineShiftsQueryHandler.cs @@ -0,0 +1,49 @@ +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Repository.Handlers.Routine; + +public class GetRoutineShiftsQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetRoutineShiftsQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + public async Task> Handle(GetRoutineShiftsQuery request, CancellationToken cancellationToken) + { + var routineShiftResponse = new List(); + + var shiftRoutines = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(s => s.RoutineId == request.Id) + .ToListAsync(cancellationToken); + foreach (var shiftRoutine in shiftRoutines) + { + var shift = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(s => s.Id == shiftRoutine.ShiftId) + .Select(ShiftMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + shift?.Days.ForEach(d => + { + var routineShiftRes = routineShiftResponse.FirstOrDefault(s => s.Day == d); + if (routineShiftRes != null) + { + routineShiftRes.Shifts.Add(shift); + } + else + { + routineShiftResponse.Add(new RoutineShiftResponseDto + { + Shifts = new List{shift}, + Day = d + }); + } + }); + } + + return routineShiftResponse; + } +} \ No newline at end of file diff --git a/Brizco.Repository/Handlers/Routine/UpdateRoutineCommandHandler.cs b/Brizco.Repository/Handlers/Routine/UpdateRoutineCommandHandler.cs index 2ffb4b8..26dc776 100644 --- a/Brizco.Repository/Handlers/Routine/UpdateRoutineCommandHandler.cs +++ b/Brizco.Repository/Handlers/Routine/UpdateRoutineCommandHandler.cs @@ -23,15 +23,11 @@ public class UpdateRoutineCommandHandler : IRequestHandler().TableNoTracking - .Where(pu => pu.PositionId == newEntity.Id) - .ToListAsync(cancellationToken); - _repositoryWrapper.SetRepository() .Update(newEntity); diff --git a/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs b/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs index c5320d4..38737e2 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs @@ -19,13 +19,16 @@ public class CreateShiftPlanCommandHandler : IRequestHandler shiftPlan.AddUser(i)); + + foreach (var userAndPositionId in request.UserAndPositionIds) + { + shiftPlan.AddUser(userAndPositionId.Key, userAndPositionId.Value); + } _repositoryWrapper.SetRepository().Add(shiftPlan); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs b/Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs index e7ca01b..6e4145a 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs @@ -24,7 +24,7 @@ public class UpdateShiftPlanCommandHandler : IRequestHandler(shiftPlanUser.PositionId,shiftPlanUser.UserId))) + request.UserAndPositionIds.Remove(new KeyValuePair(shiftPlanUser.PositionId, shiftPlanUser.UserId)); else _repositoryWrapper.SetRepository() .Delete(shiftPlanUser); } - foreach (var userId in request.UserIds) - newPlan.AddUser(userId); + foreach (var userId in request.UserAndPositionIds) + newPlan.AddUser(userId.Key,userId.Value); _repositoryWrapper.SetRepository() .Update(newPlan); diff --git a/Brizco.Repository/Migrations/20231119064231_editShiftPlan.Designer.cs b/Brizco.Repository/Migrations/20231119064231_editShiftPlan.Designer.cs new file mode 100644 index 0000000..f7fd22d --- /dev/null +++ b/Brizco.Repository/Migrations/20231119064231_editShiftPlan.Designer.cs @@ -0,0 +1,1511 @@ +// +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("20231119064231_editShiftPlan")] + partial class editShiftPlan + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "7.0.11") + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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.PositionUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationUserId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("PositionId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftPlanId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationUserId"); + + b.HasIndex("PositionId"); + + b.HasIndex("ShiftPlanId"); + + b.ToTable("PositionUsers", "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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("DayOfWeek") + .HasColumnType("integer"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanFor") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoutineId") + .HasColumnType("uuid"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoutineId"); + + b.HasIndex("ShiftId"); + + b.ToTable("ShiftPlans", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationUserId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftPlanId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationUserId"); + + b.HasIndex("ShiftPlanId"); + + 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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasDisposed") + .HasColumnType("boolean"); + + b.Property("IsDisposable") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("DayOfWeek") + .HasColumnType("integer"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("PositionId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoutineId") + .HasColumnType("uuid"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoutineId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskRoutines", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ShiftId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskShifts", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ComplexId") + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NationalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SelectedComplexUserRoleId") + .HasColumnType("uuid"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("Users", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => + { + b.HasBaseType("Brizco.Domain.Entities.Task.Task"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDone") + .HasColumnType("boolean"); + + b.Property("PerformanceDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasIndex("UserId"); + + b.HasDiscriminator().HasValue("Activity"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Users") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.ComplexUser", "ComplexUser") + .WithMany("Roles") + .HasForeignKey("ComplexUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ComplexUser"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Complex.Section", "Section") + .WithMany("Positions") + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.PositionUser", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "ApplicationUser") + .WithMany() + .HasForeignKey("ApplicationUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany("Users") + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + .WithMany() + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ApplicationUser"); + + b.Navigation("Position"); + + b.Navigation("ShiftPlan"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Shifts") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Days") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany() + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Plans") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "ApplicationUser") + .WithMany() + .HasForeignKey("ApplicationUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + .WithMany("Users") + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ApplicationUser"); + + b.Navigation("ShiftPlan"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany("Shifts") + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Routines") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Tasks") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b => + { + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Days") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskPosition", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Positions") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany("Tasks") + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Routines") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Routine"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Shifts") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Roles") + .HasForeignKey("ComplexId"); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => + { + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + { + b.Navigation("Roles"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + { + b.Navigation("Positions"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + { + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.Navigation("Days"); + + b.Navigation("Plans"); + + b.Navigation("Routines"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.Navigation("Days"); + + b.Navigation("Positions"); + + b.Navigation("Routines"); + + b.Navigation("Shifts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Brizco.Repository/Migrations/20231119064231_editShiftPlan.cs b/Brizco.Repository/Migrations/20231119064231_editShiftPlan.cs new file mode 100644 index 0000000..484872e --- /dev/null +++ b/Brizco.Repository/Migrations/20231119064231_editShiftPlan.cs @@ -0,0 +1,70 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Brizco.Repository.Migrations +{ + /// + public partial class editShiftPlan : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "PlanDate", + schema: "public", + table: "ShiftPlans", + newName: "PlanFor"); + + migrationBuilder.AddColumn( + name: "RoutineId", + schema: "public", + table: "ShiftPlans", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.CreateIndex( + name: "IX_ShiftPlans_RoutineId", + schema: "public", + table: "ShiftPlans", + column: "RoutineId"); + + migrationBuilder.AddForeignKey( + name: "FK_ShiftPlans_Routines_RoutineId", + schema: "public", + table: "ShiftPlans", + column: "RoutineId", + principalSchema: "public", + principalTable: "Routines", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ShiftPlans_Routines_RoutineId", + schema: "public", + table: "ShiftPlans"); + + migrationBuilder.DropIndex( + name: "IX_ShiftPlans_RoutineId", + schema: "public", + table: "ShiftPlans"); + + migrationBuilder.DropColumn( + name: "RoutineId", + schema: "public", + table: "ShiftPlans"); + + migrationBuilder.RenameColumn( + name: "PlanFor", + schema: "public", + table: "ShiftPlans", + newName: "PlanDate"); + } + } +} diff --git a/Brizco.Repository/Migrations/20231119172529_editShiftPlanUser.Designer.cs b/Brizco.Repository/Migrations/20231119172529_editShiftPlanUser.Designer.cs new file mode 100644 index 0000000..7d7f65d --- /dev/null +++ b/Brizco.Repository/Migrations/20231119172529_editShiftPlanUser.Designer.cs @@ -0,0 +1,1442 @@ +// +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("20231119172529_editShiftPlanUser")] + partial class editShiftPlanUser + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "7.0.11") + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("DayOfWeek") + .HasColumnType("integer"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanFor") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoutineId") + .HasColumnType("uuid"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoutineId"); + + b.HasIndex("ShiftId"); + + 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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("PositionId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasDisposed") + .HasColumnType("boolean"); + + b.Property("IsDisposable") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("DayOfWeek") + .HasColumnType("integer"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("PositionId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoutineId") + .HasColumnType("uuid"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoutineId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskRoutines", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ShiftId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskShifts", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ComplexId") + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NationalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SelectedComplexUserRoleId") + .HasColumnType("uuid"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("Users", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => + { + b.HasBaseType("Brizco.Domain.Entities.Task.Task"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDone") + .HasColumnType("boolean"); + + b.Property("PerformanceDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasIndex("UserId"); + + b.HasDiscriminator().HasValue("Activity"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Users") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.ComplexUser", "ComplexUser") + .WithMany("Roles") + .HasForeignKey("ComplexUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ComplexUser"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Complex.Section", "Section") + .WithMany("Positions") + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Shifts") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Days") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany() + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Plans") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + .WithMany("Users") + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("ShiftPlan"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany("Shifts") + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Routines") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Tasks") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b => + { + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Days") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskPosition", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Positions") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany("Tasks") + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Routines") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Routine"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Shifts") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Roles") + .HasForeignKey("ComplexId"); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => + { + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + { + b.Navigation("Roles"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + { + b.Navigation("Positions"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + { + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.Navigation("Days"); + + b.Navigation("Plans"); + + b.Navigation("Routines"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.Navigation("Days"); + + b.Navigation("Positions"); + + b.Navigation("Routines"); + + b.Navigation("Shifts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Brizco.Repository/Migrations/20231119172529_editShiftPlanUser.cs b/Brizco.Repository/Migrations/20231119172529_editShiftPlanUser.cs new file mode 100644 index 0000000..8656ced --- /dev/null +++ b/Brizco.Repository/Migrations/20231119172529_editShiftPlanUser.cs @@ -0,0 +1,177 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Brizco.Repository.Migrations +{ + /// + public partial class editShiftPlanUser : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ShiftPlanUsers_Users_ApplicationUserId", + schema: "public", + table: "ShiftPlanUsers"); + + migrationBuilder.DropTable( + name: "PositionUsers", + schema: "public"); + + migrationBuilder.RenameColumn( + name: "ApplicationUserId", + schema: "public", + table: "ShiftPlanUsers", + newName: "UserId"); + + migrationBuilder.RenameIndex( + name: "IX_ShiftPlanUsers_ApplicationUserId", + schema: "public", + table: "ShiftPlanUsers", + newName: "IX_ShiftPlanUsers_UserId"); + + migrationBuilder.AddColumn( + name: "PositionId", + schema: "public", + table: "ShiftPlanUsers", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.CreateIndex( + name: "IX_ShiftPlanUsers_PositionId", + schema: "public", + table: "ShiftPlanUsers", + column: "PositionId"); + + migrationBuilder.AddForeignKey( + name: "FK_ShiftPlanUsers_Positions_PositionId", + schema: "public", + table: "ShiftPlanUsers", + column: "PositionId", + principalSchema: "public", + principalTable: "Positions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_ShiftPlanUsers_Users_UserId", + schema: "public", + table: "ShiftPlanUsers", + column: "UserId", + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ShiftPlanUsers_Positions_PositionId", + schema: "public", + table: "ShiftPlanUsers"); + + migrationBuilder.DropForeignKey( + name: "FK_ShiftPlanUsers_Users_UserId", + schema: "public", + table: "ShiftPlanUsers"); + + migrationBuilder.DropIndex( + name: "IX_ShiftPlanUsers_PositionId", + schema: "public", + table: "ShiftPlanUsers"); + + migrationBuilder.DropColumn( + name: "PositionId", + schema: "public", + table: "ShiftPlanUsers"); + + migrationBuilder.RenameColumn( + name: "UserId", + schema: "public", + table: "ShiftPlanUsers", + newName: "ApplicationUserId"); + + migrationBuilder.RenameIndex( + name: "IX_ShiftPlanUsers_UserId", + schema: "public", + table: "ShiftPlanUsers", + newName: "IX_ShiftPlanUsers_ApplicationUserId"); + + migrationBuilder.CreateTable( + name: "PositionUsers", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ApplicationUserId = table.Column(type: "uuid", nullable: false), + PositionId = table.Column(type: "uuid", nullable: false), + ShiftPlanId = table.Column(type: "uuid", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: false), + IsRemoved = table.Column(type: "boolean", nullable: false), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + RemovedBy = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PositionUsers", x => x.Id); + table.ForeignKey( + name: "FK_PositionUsers_Positions_PositionId", + column: x => x.PositionId, + principalSchema: "public", + principalTable: "Positions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_PositionUsers_ShiftPlans_ShiftPlanId", + column: x => x.ShiftPlanId, + principalSchema: "public", + principalTable: "ShiftPlans", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_PositionUsers_Users_ApplicationUserId", + column: x => x.ApplicationUserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_PositionUsers_ApplicationUserId", + schema: "public", + table: "PositionUsers", + column: "ApplicationUserId"); + + migrationBuilder.CreateIndex( + name: "IX_PositionUsers_PositionId", + schema: "public", + table: "PositionUsers", + column: "PositionId"); + + migrationBuilder.CreateIndex( + name: "IX_PositionUsers_ShiftPlanId", + schema: "public", + table: "PositionUsers", + column: "ShiftPlanId"); + + migrationBuilder.AddForeignKey( + name: "FK_ShiftPlanUsers_Users_ApplicationUserId", + schema: "public", + table: "ShiftPlanUsers", + column: "ApplicationUserId", + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs index 15c2305..78e274a 100644 --- a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -213,56 +213,6 @@ namespace Brizco.Repository.Migrations b.ToTable("Positions", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.PositionUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("PositionId") - .HasColumnType("uuid"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("ShiftPlanId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("PositionId"); - - b.HasIndex("ShiftPlanId"); - - b.ToTable("PositionUsers", "public"); - }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => { b.Property("Id") @@ -479,7 +429,7 @@ namespace Brizco.Repository.Migrations .IsRequired() .HasColumnType("text"); - b.Property("PlanDate") + b.Property("PlanFor") .HasColumnType("timestamp without time zone"); b.Property("RemovedAt") @@ -489,11 +439,16 @@ namespace Brizco.Repository.Migrations .IsRequired() .HasColumnType("text"); + b.Property("RoutineId") + .HasColumnType("uuid"); + b.Property("ShiftId") .HasColumnType("uuid"); b.HasKey("Id"); + b.HasIndex("RoutineId"); + b.HasIndex("ShiftId"); b.ToTable("ShiftPlans", "public"); @@ -505,9 +460,6 @@ namespace Brizco.Repository.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - b.Property("CreatedAt") .HasColumnType("timestamp without time zone"); @@ -525,6 +477,9 @@ namespace Brizco.Repository.Migrations .IsRequired() .HasColumnType("text"); + b.Property("PositionId") + .HasColumnType("uuid"); + b.Property("RemovedAt") .HasColumnType("timestamp without time zone"); @@ -535,12 +490,17 @@ namespace Brizco.Repository.Migrations b.Property("ShiftPlanId") .HasColumnType("uuid"); + b.Property("UserId") + .HasColumnType("uuid"); + b.HasKey("Id"); - b.HasIndex("ApplicationUserId"); + b.HasIndex("PositionId"); b.HasIndex("ShiftPlanId"); + b.HasIndex("UserId"); + b.ToTable("ShiftPlanUsers", "public"); }); @@ -1162,33 +1122,6 @@ namespace Brizco.Repository.Migrations b.Navigation("Section"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.PositionUser", b => - { - b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") - .WithMany("Users") - .HasForeignKey("PositionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") - .WithMany() - .HasForeignKey("ShiftPlanId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Position"); - - b.Navigation("ShiftPlan"); - }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => { b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") @@ -1235,20 +1168,28 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany() + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") .WithMany("Plans") .HasForeignKey("ShiftId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); + b.Navigation("Routine"); + b.Navigation("Shift"); }); modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => { - b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "ApplicationUser") + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") .WithMany() - .HasForeignKey("ApplicationUserId") + .HasForeignKey("PositionId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -1258,9 +1199,17 @@ namespace Brizco.Repository.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.Navigation("ApplicationUser"); + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Position"); b.Navigation("ShiftPlan"); + + b.Navigation("User"); }); modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftRoutine", b => @@ -1306,7 +1255,7 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskPosition", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Position", "Role") + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") .WithMany() .HasForeignKey("PositionId") .OnDelete(DeleteBehavior.Restrict) @@ -1318,7 +1267,7 @@ namespace Brizco.Repository.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.Navigation("Role"); + b.Navigation("Position"); b.Navigation("Task"); }); @@ -1448,11 +1397,6 @@ namespace Brizco.Repository.Migrations b.Navigation("Roles"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b => - { - b.Navigation("Users"); - }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => { b.Navigation("Positions");