From 9092109cd283fe2467d3b6122322425efec6e608 Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Sun, 5 Nov 2023 18:00:05 +0330 Subject: [PATCH] complete shifting and add version 0.1.0.3 --- .version | 2 +- Brizco.Api/Brizco.Api.csproj | 5 +- Brizco.Api/Controllers/AuthController.cs | 7 +- Brizco.Api/Controllers/HealthController.cs | 34 + Brizco.Api/Controllers/ShiftPlanController.cs | 50 + Brizco.Common/Models/Api/HealthCheck.cs | 7 +- .../Abstracts/IShiftPlanService.cs | 6 + .../EntityServices/ShiftPlanService.cs | 18 + .../Commands/ActivityCommands.cs | 2 - .../CommandQueries/Commands/ShiftCommands.cs | 4 +- .../Commands/ShiftPlanCommands.cs | 6 +- Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs | 1 - .../Entities/Shift/Aggregate.Shift.cs | 11 +- Brizco.Domain/Entities/Shift/Shift.cs | 2 - Brizco.Domain/Entities/Shift/ShiftDay.cs | 20 - Brizco.Domain/Entities/Shift/ShiftPlan.cs | 9 +- Brizco.Domain/Entities/Task/Activity.cs | 15 +- Brizco.Domain/Entities/Task/Aggregate.Task.cs | 3 - Brizco.Domain/Entities/Task/Task.cs | 5 +- Brizco.Domain/Mappers/ActivityMapper.g.cs | 12 - Brizco.Domain/Mappers/ShiftMapper.g.cs | 199 +-- Brizco.Domain/Mappers/ShiftPlanMapper.g.cs | 24 - Brizco.Domain/Mappers/TaskMapper.g.cs | 12 - Brizco.Domain/MapsterRegister.cs | 1 - .../Activity/CreateActivityCommandHandler.cs | 7 - .../Activity/UpdateActivityCommandHandler.cs | 1 - .../Shift/CreateShiftCommandHandler.cs | 2 - .../Handlers/Shift/GetShiftsQueryHandler.cs | 4 - .../Shift/UpdateShiftCommandHandler.cs | 23 +- .../CreateShiftPlanCommandHandler.cs | 2 +- .../DeleteShiftPlanCommandHandler.cs | 2 +- .../UpdateShiftPlanCommandHandler.cs | 2 +- .../Handlers/Task/CreateTaskCommandHandler.cs | 7 - .../20231104072034_editShift.Designer.cs | 1079 +++++++++++++++++ .../Migrations/20231104072034_editShift.cs | 95 ++ .../ApplicationContextModelSnapshot.cs | 68 +- 36 files changed, 1364 insertions(+), 383 deletions(-) create mode 100644 Brizco.Api/Controllers/HealthController.cs create mode 100644 Brizco.Api/Controllers/ShiftPlanController.cs create mode 100644 Brizco.Core/EntityServices/Abstracts/IShiftPlanService.cs create mode 100644 Brizco.Core/EntityServices/ShiftPlanService.cs delete mode 100644 Brizco.Domain/Entities/Shift/ShiftDay.cs create mode 100644 Brizco.Repository/Migrations/20231104072034_editShift.Designer.cs create mode 100644 Brizco.Repository/Migrations/20231104072034_editShift.cs diff --git a/.version b/.version index 8901036..b8e6ed9 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.1.0.2 \ No newline at end of file +0.1.0.3 \ No newline at end of file diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj index 097514c..b04b535 100644 --- a/Brizco.Api/Brizco.Api.csproj +++ b/Brizco.Api/Brizco.Api.csproj @@ -6,8 +6,8 @@ enable Linux ..\docker-compose.dcproj - 0.1.0.2 - 0.1.0.2 + 0.1.0.3 + 0.1.0.3 @@ -59,6 +59,7 @@ + diff --git a/Brizco.Api/Controllers/AuthController.cs b/Brizco.Api/Controllers/AuthController.cs index da0b5ed..fd751f6 100644 --- a/Brizco.Api/Controllers/AuthController.cs +++ b/Brizco.Api/Controllers/AuthController.cs @@ -1,9 +1,4 @@ -using Brizco.Common.Models.Api; -using Brizco.Core.BaseServices; -using Brizco.Core.CoreServices.Abstracts; -using Microsoft.AspNetCore.Authorization.Infrastructure; - -namespace Brizco.Api.Controllers; +namespace Brizco.Api.Controllers; public class AuthController : ICarterModule { diff --git a/Brizco.Api/Controllers/HealthController.cs b/Brizco.Api/Controllers/HealthController.cs new file mode 100644 index 0000000..934d3fe --- /dev/null +++ b/Brizco.Api/Controllers/HealthController.cs @@ -0,0 +1,34 @@ +using Brizco.Common.Models.Api; +using MD.PersianDateTime.Standard; +using System.Diagnostics; + +namespace Brizco.Api.Controllers; + +public class HealthController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Health") + .MapGroup($"health"); + + group.MapGet("", GetHealth) + .WithDisplayName("CheckHealth") + .HasApiVersion(1.0); + } + public IResult GetHealth() + { + var version = typeof(Program)?.Assembly.GetName()?.Version?.ToString(); + var check = new HealthCheck + { + Health = true, + Version = version ?? string.Empty, + StartAt = System.Diagnostics.Process.GetCurrentProcess().StartTime.ToString("F"), + StartAtPersian = new PersianDateTime(System.Diagnostics.Process.GetCurrentProcess().StartTime).ToLongDateTimeString(), + MachineName = Environment.MachineName + }; + var process = Process.GetCurrentProcess(); + check.TotalMemory = process.PrivateMemorySize64.ToString(); + + return TypedResults.Ok(check); + } +} \ No newline at end of file diff --git a/Brizco.Api/Controllers/ShiftPlanController.cs b/Brizco.Api/Controllers/ShiftPlanController.cs new file mode 100644 index 0000000..e0f0b9f --- /dev/null +++ b/Brizco.Api/Controllers/ShiftPlanController.cs @@ -0,0 +1,50 @@ +namespace Brizco.Api.Controllers; + +public class ShiftPlanController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + + var group = app.NewVersionedApi("ShiftPlan") + .MapGroup($"api/shift/plan") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetShiftPlans") + .HasApiVersion(1.0); + + group.MapGet("{id:guid}", GetAsync) + .WithDisplayName("GetShiftPlan") + .HasApiVersion(1.0); + + group.MapPost("", Post) + .HasApiVersion(1.0); + + group.MapPut("", Put) + .HasApiVersion(1.0); + + group.MapDelete("{id:guid}", Delete) + .HasApiVersion(1.0); + + } + + // GET:Get All Entity + public async Task GetAllAsync([FromQuery] int page, ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetShiftPlansQuery(page), cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetShiftPlanQuery(id))); + + // POST:Create Entity + public async Task Post([FromBody] CreateShiftPlanCommand ent, ISender mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(ent, cancellationToken)); + + // PUT:Update Entity + public async Task Put([FromBody] UpdateShiftPlanCommand ent, ISender mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(ent, cancellationToken)); + + // DELETE:Delete Entity + public async Task Delete(Guid id, ISender mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new DeleteShiftPlanCommand(id), cancellationToken)); +} \ No newline at end of file diff --git a/Brizco.Common/Models/Api/HealthCheck.cs b/Brizco.Common/Models/Api/HealthCheck.cs index a552b30..bbff7e7 100644 --- a/Brizco.Common/Models/Api/HealthCheck.cs +++ b/Brizco.Common/Models/Api/HealthCheck.cs @@ -3,7 +3,10 @@ public class HealthCheck { public bool Health { get; set; } - public string Version { get; set; } - public string TotalMemory { get; set; } + public string Version { get; set; } = string.Empty; + public string TotalMemory { get; set; } = string.Empty; + public string StartAt { get; set; } = string.Empty; + public string StartAtPersian { get; set; } = string.Empty; + public string MachineName { get; set; } = string.Empty; } } \ No newline at end of file diff --git a/Brizco.Core/EntityServices/Abstracts/IShiftPlanService.cs b/Brizco.Core/EntityServices/Abstracts/IShiftPlanService.cs new file mode 100644 index 0000000..3d8bfad --- /dev/null +++ b/Brizco.Core/EntityServices/Abstracts/IShiftPlanService.cs @@ -0,0 +1,6 @@ +namespace Brizco.Core.EntityServices.Abstracts; + +public interface IShiftPlanService +{ + Task ChangeShiftPlanTaskStatusAsync(Guid shiftPlanId,bool isChangeToShift , bool isDisable); +} \ No newline at end of file diff --git a/Brizco.Core/EntityServices/ShiftPlanService.cs b/Brizco.Core/EntityServices/ShiftPlanService.cs new file mode 100644 index 0000000..a9d9072 --- /dev/null +++ b/Brizco.Core/EntityServices/ShiftPlanService.cs @@ -0,0 +1,18 @@ +using Brizco.Domain.CommandQueries.Queries; + +namespace Brizco.Core.EntityServices; + +public class ShiftPlanService : IShiftPlanService +{ + private readonly ISender _sender; + + public ShiftPlanService(ISender sender) + { + _sender = sender; + } + public async Task ChangeShiftPlanTaskStatusAsync(Guid shiftPlanId, bool isChangeToShift, bool isDisable) + { + var shiftPlan = await _sender.Send(new GetShiftPlanQuery(shiftPlanId)); + + } +} \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs b/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs index b46a811..61c727c 100644 --- a/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs @@ -7,7 +7,6 @@ public sealed record CreateActivityCommand( TaskType Type, string Title, string Description, - bool IsRelatedToShift, bool IsRelatedToRole, bool IsRelatedToPerson, bool IsDisposable, @@ -26,7 +25,6 @@ public sealed record UpdateActivityCommand(Guid Id, TaskType Type, string Title, string Description, - bool IsRelatedToShift, bool IsRelatedToRole, bool IsRelatedToPerson, bool IsDisposable, diff --git a/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs b/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs index 63d54a2..ff3a09e 100644 --- a/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs @@ -2,10 +2,10 @@ namespace Brizco.Domain.CommandQueries.Commands; -public sealed record CreateShiftCommand(string Title, TimeSpan StartAt, TimeSpan EndAt, string Description , List DayOfWeeks) +public sealed record CreateShiftCommand(string Title, TimeSpan StartAt, TimeSpan EndAt, string Description ) : IRequest; -public sealed record UpdateShiftCommand(Guid Id,string Title, TimeSpan StartAt, TimeSpan EndAt, string Description, List DayOfWeeks) +public sealed record UpdateShiftCommand(Guid Id,string Title, TimeSpan StartAt, TimeSpan EndAt, string Description) : IRequest; public sealed record DeleteShiftCommand(Guid Id) diff --git a/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs b/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs index 3bf2ad6..aad000b 100644 --- a/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs @@ -1,10 +1,10 @@ namespace Brizco.Domain.CommandQueries.Commands; -public record CreateShiftPlanCommand(DateTime StartAt, DateTime EndAt,Guid ShiftId,List UserIds) +public record CreateShiftPlanCommand(DateTime PlanDate,Guid ShiftId,List UserIds) :IRequest; -public record UpdateShiftPlanCommand(Guid Id,DateTime StartAt, DateTime EndAt, Guid ShiftId, List UserIds) +public record UpdateShiftPlanCommand(Guid Id,DateTime PlanDate, Guid ShiftId, List UserIds) : IRequest; -public record DeleteShiftPlanCommand(Guid Id, DateTime StartAt, DateTime EndAt, Guid ShiftId, List UserIds) +public record DeleteShiftPlanCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs index fcc9791..4cb97df 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs @@ -7,6 +7,5 @@ public class ShiftSDto : BaseDto public string Description { get; set; } = string.Empty; public TimeSpan StartAt { get; set; } public TimeSpan EndAt { get; set; } - public List Days { get; set; } = new(); public Guid ComplexId { get; set; } } diff --git a/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs b/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs index d3e311e..5f01f30 100644 --- a/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs +++ b/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs @@ -8,16 +8,9 @@ public partial class Shift return new Shift(title, description, startAt, endAt,complexId); } - public ShiftDay SetDay(DayOfWeek dayOfWeek) + public ShiftPlan AddPlan(DateTime planDate) { - var shiftDay = new ShiftDay(dayOfWeek , Id); - Days.Add(shiftDay); - return shiftDay; - } - - public ShiftPlan AddPlan(DateTime startAt, DateTime endAt) - { - var plan = new ShiftPlan(startAt, endAt , Id); + var plan = new ShiftPlan(planDate , Id); Plans.Add(plan); return plan; } diff --git a/Brizco.Domain/Entities/Shift/Shift.cs b/Brizco.Domain/Entities/Shift/Shift.cs index 12a25c0..793aefd 100644 --- a/Brizco.Domain/Entities/Shift/Shift.cs +++ b/Brizco.Domain/Entities/Shift/Shift.cs @@ -23,7 +23,5 @@ public partial class Shift : ApiEntity public Guid ComplexId { get; set; } public Complex.Complex? Complex { get; set; } - public List Days { get; internal set; } = new(); - public List Plans { get; internal set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Shift/ShiftDay.cs b/Brizco.Domain/Entities/Shift/ShiftDay.cs deleted file mode 100644 index f31bf4d..0000000 --- a/Brizco.Domain/Entities/Shift/ShiftDay.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Brizco.Domain.Entities.Shift; - -public class ShiftDay : ApiEntity -{ - public ShiftDay() - { - - } - - internal ShiftDay(DayOfWeek dayOfWeek,Guid shiftId) - { - DayOfWeek = dayOfWeek; - ShiftId = shiftId; - } - - public DayOfWeek DayOfWeek { get; internal set; } - - public Guid ShiftId { get; internal set; } - public Shift? Shift { get; internal set; } -} \ No newline at end of file diff --git a/Brizco.Domain/Entities/Shift/ShiftPlan.cs b/Brizco.Domain/Entities/Shift/ShiftPlan.cs index 59ef8b8..21f6c53 100644 --- a/Brizco.Domain/Entities/Shift/ShiftPlan.cs +++ b/Brizco.Domain/Entities/Shift/ShiftPlan.cs @@ -10,13 +10,12 @@ public partial class ShiftPlan : ApiEntity } - internal ShiftPlan(DateTime startAt, DateTime endAt,Guid shiftId) + internal ShiftPlan(DateTime planDate,Guid shiftId) { - StartAt = startAt; - EndAt = endAt; + PlanDate = planDate; + ShiftId = shiftId; } - public DateTime StartAt { get; internal set; } - public DateTime EndAt { get; internal set; } + public DateTime PlanDate { get; internal set; } public Guid ShiftId { get; internal set; } public virtual Shift? Shift { get; internal set; } diff --git a/Brizco.Domain/Entities/Task/Activity.cs b/Brizco.Domain/Entities/Task/Activity.cs index fe7c87a..ed304dc 100644 --- a/Brizco.Domain/Entities/Task/Activity.cs +++ b/Brizco.Domain/Entities/Task/Activity.cs @@ -15,7 +15,6 @@ public partial class Activity : Task DateTime doneAt, string performanceDescription, TaskType type, - bool isRelatedToShift, bool isRelatedToRole, bool isRelatedToPerson, bool isDisposable, @@ -25,18 +24,8 @@ public partial class Activity : Task PurchaseAmountType amountType, string title, string description, - Guid complexId) : base(type, - isRelatedToShift, - isRelatedToRole, - isRelatedToPerson, - isDisposable, - setFor, - hasDisposed, - amount, - amountType, - title, - description, - complexId) + Guid complexId) : base( + type,isRelatedToRole, isRelatedToPerson, isDisposable, setFor, hasDisposed, amount, amountType, title, description, complexId) { Status = status; DoneAt = doneAt; diff --git a/Brizco.Domain/Entities/Task/Aggregate.Task.cs b/Brizco.Domain/Entities/Task/Aggregate.Task.cs index 357dda5..9fce992 100644 --- a/Brizco.Domain/Entities/Task/Aggregate.Task.cs +++ b/Brizco.Domain/Entities/Task/Aggregate.Task.cs @@ -19,7 +19,6 @@ public partial class Task Guid complexId) { return new Task(type, - isRelatedToShift, isRelatedToRole, isRelatedToPerson, isDisposable, @@ -97,7 +96,6 @@ public partial class Activity string title, string description, TaskType type, - bool isRelatedToShift, bool isRelatedToRole, bool isRelatedToPerson, bool isDisposable, @@ -112,7 +110,6 @@ public partial class Activity doneAt, performanceDescription, type, - isRelatedToShift, isRelatedToRole, isRelatedToPerson, isDisposable, diff --git a/Brizco.Domain/Entities/Task/Task.cs b/Brizco.Domain/Entities/Task/Task.cs index 1a31b79..ad9f6c1 100644 --- a/Brizco.Domain/Entities/Task/Task.cs +++ b/Brizco.Domain/Entities/Task/Task.cs @@ -12,7 +12,6 @@ public partial class Task : ApiEntity } internal Task( TaskType type, - bool isRelatedToShift, bool isRelatedToRole, bool isRelatedToPerson, bool isDisposable, @@ -25,7 +24,6 @@ public partial class Task : ApiEntity Guid complexId) { Type = type; - IsRelatedToShift = isRelatedToShift; IsRelatedToRole = isRelatedToRole; IsRelatedToPerson = isRelatedToPerson; IsDisposable = isDisposable; @@ -41,7 +39,6 @@ public partial class Task : ApiEntity public TaskType Type { get; internal set; } public string Title { get; internal set; } = string.Empty; public string Description { get; internal set; } = string.Empty; - public bool IsRelatedToShift { get; internal set; } public bool IsRelatedToRole { get; internal set; } public bool IsRelatedToPerson { get; internal set; } public bool IsDisposable { get; internal set; } @@ -60,7 +57,7 @@ public partial class Task : ApiEntity public List Shifts { get; internal set; } = new(); - public List Days { get; internal set; } + public List Days { get; internal set; } = new(); public List Roles { get; internal set; } = new(); } diff --git a/Brizco.Domain/Mappers/ActivityMapper.g.cs b/Brizco.Domain/Mappers/ActivityMapper.g.cs index a36a293..f93c86a 100644 --- a/Brizco.Domain/Mappers/ActivityMapper.g.cs +++ b/Brizco.Domain/Mappers/ActivityMapper.g.cs @@ -19,7 +19,6 @@ namespace Brizco.Domain.Mappers Type = p1.Type, Title = p1.Title, Description = p1.Description, - IsRelatedToShift = p1.IsRelatedToShift, IsRelatedToRole = p1.IsRelatedToRole, IsRelatedToPerson = p1.IsRelatedToPerson, IsDisposable = p1.IsDisposable, @@ -45,7 +44,6 @@ namespace Brizco.Domain.Mappers result.Type = p2.Type; result.Title = p2.Title; result.Description = p2.Description; - result.IsRelatedToShift = p2.IsRelatedToShift; result.IsRelatedToRole = p2.IsRelatedToRole; result.IsRelatedToPerson = p2.IsRelatedToPerson; result.IsDisposable = p2.IsDisposable; @@ -66,7 +64,6 @@ namespace Brizco.Domain.Mappers Type = p4.Type, Title = p4.Title, Description = p4.Description, - IsRelatedToShift = p4.IsRelatedToShift, IsRelatedToRole = p4.IsRelatedToRole, IsRelatedToPerson = p4.IsRelatedToPerson, IsDisposable = p4.IsDisposable, @@ -83,7 +80,6 @@ namespace Brizco.Domain.Mappers Type = p5.Type, Title = p5.Title, Description = p5.Description, - IsRelatedToShift = p5.IsRelatedToShift, IsRelatedToRole = p5.IsRelatedToRole, IsRelatedToPerson = p5.IsRelatedToPerson, IsDisposable = p5.IsDisposable, @@ -109,7 +105,6 @@ namespace Brizco.Domain.Mappers result.Type = p6.Type; result.Title = p6.Title; result.Description = p6.Description; - result.IsRelatedToShift = p6.IsRelatedToShift; result.IsRelatedToRole = p6.IsRelatedToRole; result.IsRelatedToPerson = p6.IsRelatedToPerson; result.IsDisposable = p6.IsDisposable; @@ -130,7 +125,6 @@ namespace Brizco.Domain.Mappers Type = p8.Type, Title = p8.Title, Description = p8.Description, - IsRelatedToShift = p8.IsRelatedToShift, IsRelatedToRole = p8.IsRelatedToRole, IsRelatedToPerson = p8.IsRelatedToPerson, IsDisposable = p8.IsDisposable, @@ -155,7 +149,6 @@ namespace Brizco.Domain.Mappers Type = p9.Type, Title = p9.Title, Description = p9.Description, - IsRelatedToShift = p9.IsRelatedToShift, IsRelatedToRole = p9.IsRelatedToRole, IsRelatedToPerson = p9.IsRelatedToPerson, IsDisposable = p9.IsDisposable, @@ -181,7 +174,6 @@ namespace Brizco.Domain.Mappers result.Type = p10.Type; result.Title = p10.Title; result.Description = p10.Description; - result.IsRelatedToShift = p10.IsRelatedToShift; result.IsRelatedToRole = p10.IsRelatedToRole; result.IsRelatedToPerson = p10.IsRelatedToPerson; result.IsDisposable = p10.IsDisposable; @@ -202,7 +194,6 @@ namespace Brizco.Domain.Mappers Type = p12.Type, Title = p12.Title, Description = p12.Description, - IsRelatedToShift = p12.IsRelatedToShift, IsRelatedToRole = p12.IsRelatedToRole, IsRelatedToPerson = p12.IsRelatedToPerson, IsDisposable = p12.IsDisposable, @@ -219,7 +210,6 @@ namespace Brizco.Domain.Mappers Type = p13.Type, Title = p13.Title, Description = p13.Description, - IsRelatedToShift = p13.IsRelatedToShift, IsRelatedToRole = p13.IsRelatedToRole, IsRelatedToPerson = p13.IsRelatedToPerson, IsDisposable = p13.IsDisposable, @@ -245,7 +235,6 @@ namespace Brizco.Domain.Mappers result.Type = p14.Type; result.Title = p14.Title; result.Description = p14.Description; - result.IsRelatedToShift = p14.IsRelatedToShift; result.IsRelatedToRole = p14.IsRelatedToRole; result.IsRelatedToPerson = p14.IsRelatedToPerson; result.IsDisposable = p14.IsDisposable; @@ -266,7 +255,6 @@ namespace Brizco.Domain.Mappers Type = p16.Type, Title = p16.Title, Description = p16.Description, - IsRelatedToShift = p16.IsRelatedToShift, IsRelatedToRole = p16.IsRelatedToRole, IsRelatedToPerson = p16.IsRelatedToPerson, IsDisposable = p16.IsDisposable, diff --git a/Brizco.Domain/Mappers/ShiftMapper.g.cs b/Brizco.Domain/Mappers/ShiftMapper.g.cs index dd7f8a9..b50ad31 100644 --- a/Brizco.Domain/Mappers/ShiftMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftMapper.g.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; using Brizco.Domain.Dtos.SmallDtos; using Brizco.Domain.Entities.Complex; @@ -21,176 +19,81 @@ namespace Brizco.Domain.Mappers Description = p1.Description, ComplexId = p1.ComplexId, Complex = new Complex() {Id = p1.ComplexId}, - Days = funcMain1(p1.Days), Id = p1.Id }; } - public static Shift AdaptTo(this ShiftSDto p3, Shift p4) - { - if (p3 == null) - { - return null; - } - Shift result = p4 ?? new Shift(); - - result.Title = p3.Title; - result.StartAt = p3.StartAt; - result.EndAt = p3.EndAt; - result.Description = p3.Description; - result.ComplexId = p3.ComplexId; - result.Complex = funcMain2(new Never(), result.Complex, p3); - result.Days = funcMain3(p3.Days, result.Days); - result.Id = p3.Id; - return result; - - } - public static Expression> ProjectToShift => p9 => new Shift() - { - Title = p9.Title, - StartAt = p9.StartAt, - EndAt = p9.EndAt, - Description = p9.Description, - ComplexId = p9.ComplexId, - Complex = new Complex() {Id = p9.ComplexId}, - Days = p9.Days.Select(p10 => new ShiftDay() {}).ToList(), - Id = p9.Id - }; - public static ShiftSDto AdaptToSDto(this Shift p11) - { - return p11 == null ? null : new ShiftSDto() - { - Title = p11.Title, - Description = p11.Description, - StartAt = p11.StartAt, - EndAt = p11.EndAt, - Days = funcMain4(p11.Days.Select(funcMain5).ToList()), - ComplexId = p11.ComplexId, - Id = p11.Id - }; - } - public static ShiftSDto AdaptTo(this Shift p13, ShiftSDto p14) - { - if (p13 == null) - { - return null; - } - ShiftSDto result = p14 ?? new ShiftSDto(); - - result.Title = p13.Title; - result.Description = p13.Description; - result.StartAt = p13.StartAt; - result.EndAt = p13.EndAt; - result.Days = funcMain6(p13.Days.Select(funcMain5).ToList(), result.Days); - result.ComplexId = p13.ComplexId; - result.Id = p13.Id; - return result; - - } - public static Expression> ProjectToSDto => p17 => new ShiftSDto() - { - Title = p17.Title, - Description = p17.Description, - StartAt = p17.StartAt, - EndAt = p17.EndAt, - Days = p17.Days.Select(d => d.DayOfWeek).ToList(), - ComplexId = p17.ComplexId, - Id = p17.Id - }; - - private static List funcMain1(List p2) + public static Shift AdaptTo(this ShiftSDto p2, Shift p3) { if (p2 == null) { return null; } - List result = new List(p2.Count); + Shift result = p3 ?? new Shift(); - int i = 0; - int len = p2.Count; + result.Title = p2.Title; + result.StartAt = p2.StartAt; + result.EndAt = p2.EndAt; + result.Description = p2.Description; + result.ComplexId = p2.ComplexId; + result.Complex = funcMain1(new Never(), result.Complex, p2); + result.Id = p2.Id; + return result; - while (i < len) + } + public static Expression> ProjectToShift => p6 => new Shift() + { + Title = p6.Title, + StartAt = p6.StartAt, + EndAt = p6.EndAt, + Description = p6.Description, + ComplexId = p6.ComplexId, + Complex = new Complex() {Id = p6.ComplexId}, + Id = p6.Id + }; + public static ShiftSDto AdaptToSDto(this Shift p7) + { + return p7 == null ? null : new ShiftSDto() { - DayOfWeek item = p2[i]; - result.Add(new ShiftDay() {}); - i++; - } - return result; - + Title = p7.Title, + Description = p7.Description, + StartAt = p7.StartAt, + EndAt = p7.EndAt, + ComplexId = p7.ComplexId, + Id = p7.Id + }; } - - private static Complex funcMain2(Never p5, Complex p6, ShiftSDto p3) + public static ShiftSDto AdaptTo(this Shift p8, ShiftSDto p9) { - Complex result = p6 ?? new Complex(); - - result.Id = p3.ComplexId; - return result; - - } - - private static List funcMain3(List p7, List p8) - { - if (p7 == null) + if (p8 == null) { return null; } - List result = new List(p7.Count); + ShiftSDto result = p9 ?? new ShiftSDto(); - int i = 0; - int len = p7.Count; - - while (i < len) - { - DayOfWeek item = p7[i]; - result.Add(new ShiftDay() {}); - i++; - } + result.Title = p8.Title; + result.Description = p8.Description; + result.StartAt = p8.StartAt; + result.EndAt = p8.EndAt; + result.ComplexId = p8.ComplexId; + result.Id = p8.Id; return result; } - - private static List funcMain4(List p12) + public static Expression> ProjectToSDto => p10 => new ShiftSDto() { - if (p12 == null) - { - return null; - } - List result = new List(p12.Count); - - int i = 0; - int len = p12.Count; - - while (i < len) - { - DayOfWeek item = p12[i]; - result.Add(item); - i++; - } - return result; - - } + Title = p10.Title, + Description = p10.Description, + StartAt = p10.StartAt, + EndAt = p10.EndAt, + ComplexId = p10.ComplexId, + Id = p10.Id + }; - private static DayOfWeek funcMain5(ShiftDay d) + private static Complex funcMain1(Never p4, Complex p5, ShiftSDto p2) { - return d.DayOfWeek; - } - - private static List funcMain6(List p15, List p16) - { - if (p15 == null) - { - return null; - } - List result = new List(p15.Count); + Complex result = p5 ?? new Complex(); - int i = 0; - int len = p15.Count; - - while (i < len) - { - DayOfWeek item = p15[i]; - result.Add(item); - i++; - } + result.Id = p2.ComplexId; return result; } diff --git a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs index be7a2cd..bd092ec 100644 --- a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs @@ -14,8 +14,6 @@ namespace Brizco.Domain.Mappers { return p1 == null ? null : new ShiftPlan() { - StartAt = p1.StartAt, - EndAt = p1.EndAt, ShiftId = p1.ShiftId, Id = p1.Id }; @@ -28,8 +26,6 @@ namespace Brizco.Domain.Mappers } ShiftPlan result = p3 ?? new ShiftPlan(); - result.StartAt = p2.StartAt; - result.EndAt = p2.EndAt; result.ShiftId = p2.ShiftId; result.Id = p2.Id; return result; @@ -37,8 +33,6 @@ namespace Brizco.Domain.Mappers } public static Expression> ProjectToShiftPlan => p4 => new ShiftPlan() { - StartAt = p4.StartAt, - EndAt = p4.EndAt, ShiftId = p4.ShiftId, Id = p4.Id }; @@ -46,8 +40,6 @@ namespace Brizco.Domain.Mappers { return p5 == null ? null : new ShiftPlanSDto() { - StartAt = p5.StartAt, - EndAt = p5.EndAt, ShiftId = p5.ShiftId, ShiftTitle = p5.Shift == null ? null : p5.Shift.Title, Id = p5.Id @@ -61,8 +53,6 @@ namespace Brizco.Domain.Mappers } ShiftPlanSDto result = p7 ?? new ShiftPlanSDto(); - result.StartAt = p6.StartAt; - result.EndAt = p6.EndAt; result.ShiftId = p6.ShiftId; result.ShiftTitle = p6.Shift == null ? null : p6.Shift.Title; result.Id = p6.Id; @@ -71,8 +61,6 @@ namespace Brizco.Domain.Mappers } public static Expression> ProjectToSDto => p8 => new ShiftPlanSDto() { - StartAt = p8.StartAt, - EndAt = p8.EndAt, ShiftId = p8.ShiftId, ShiftTitle = p8.Shift.Title, Id = p8.Id @@ -81,8 +69,6 @@ namespace Brizco.Domain.Mappers { return p9 == null ? null : new ShiftPlan() { - StartAt = p9.StartAt, - EndAt = p9.EndAt, ShiftId = p9.ShiftId, Users = funcMain1(p9.Users), Id = p9.Id @@ -96,8 +82,6 @@ namespace Brizco.Domain.Mappers } ShiftPlan result = p12 ?? new ShiftPlan(); - result.StartAt = p11.StartAt; - result.EndAt = p11.EndAt; result.ShiftId = p11.ShiftId; result.Users = funcMain2(p11.Users, result.Users); result.Id = p11.Id; @@ -106,8 +90,6 @@ namespace Brizco.Domain.Mappers } public static Expression> ProjectLDtoToShiftPlan => p15 => new ShiftPlan() { - StartAt = p15.StartAt, - EndAt = p15.EndAt, ShiftId = p15.ShiftId, Users = p15.Users.Select(p16 => new ShiftPlanUser() { @@ -121,8 +103,6 @@ namespace Brizco.Domain.Mappers { return p17 == null ? null : new ShiftPlanLDto() { - StartAt = p17.StartAt, - EndAt = p17.EndAt, ShiftId = p17.ShiftId, Users = funcMain3(p17.Users), Id = p17.Id @@ -136,8 +116,6 @@ namespace Brizco.Domain.Mappers } ShiftPlanLDto result = p20 ?? new ShiftPlanLDto(); - result.StartAt = p19.StartAt; - result.EndAt = p19.EndAt; result.ShiftId = p19.ShiftId; result.Users = funcMain4(p19.Users, result.Users); result.Id = p19.Id; @@ -146,8 +124,6 @@ namespace Brizco.Domain.Mappers } public static Expression> ProjectToLDto => p23 => new ShiftPlanLDto() { - StartAt = p23.StartAt, - EndAt = p23.EndAt, ShiftId = p23.ShiftId, Users = p23.Users.Select(p24 => new ShiftPlanUserSDto() { diff --git a/Brizco.Domain/Mappers/TaskMapper.g.cs b/Brizco.Domain/Mappers/TaskMapper.g.cs index 993e866..05555b8 100644 --- a/Brizco.Domain/Mappers/TaskMapper.g.cs +++ b/Brizco.Domain/Mappers/TaskMapper.g.cs @@ -18,7 +18,6 @@ namespace Brizco.Domain.Mappers Type = p1.Type, Title = p1.Title, Description = p1.Description, - IsRelatedToShift = p1.IsRelatedToShift, IsRelatedToRole = p1.IsRelatedToRole, IsRelatedToPerson = p1.IsRelatedToPerson, IsDisposable = p1.IsDisposable, @@ -41,7 +40,6 @@ namespace Brizco.Domain.Mappers result.Type = p2.Type; result.Title = p2.Title; result.Description = p2.Description; - result.IsRelatedToShift = p2.IsRelatedToShift; result.IsRelatedToRole = p2.IsRelatedToRole; result.IsRelatedToPerson = p2.IsRelatedToPerson; result.IsDisposable = p2.IsDisposable; @@ -59,7 +57,6 @@ namespace Brizco.Domain.Mappers Type = p4.Type, Title = p4.Title, Description = p4.Description, - IsRelatedToShift = p4.IsRelatedToShift, IsRelatedToRole = p4.IsRelatedToRole, IsRelatedToPerson = p4.IsRelatedToPerson, IsDisposable = p4.IsDisposable, @@ -77,7 +74,6 @@ namespace Brizco.Domain.Mappers Type = p5.Type, Title = p5.Title, Description = p5.Description, - IsRelatedToShift = p5.IsRelatedToShift, IsRelatedToRole = p5.IsRelatedToRole, IsRelatedToPerson = p5.IsRelatedToPerson, IsDisposable = p5.IsDisposable, @@ -100,7 +96,6 @@ namespace Brizco.Domain.Mappers result.Type = p6.Type; result.Title = p6.Title; result.Description = p6.Description; - result.IsRelatedToShift = p6.IsRelatedToShift; result.IsRelatedToRole = p6.IsRelatedToRole; result.IsRelatedToPerson = p6.IsRelatedToPerson; result.IsDisposable = p6.IsDisposable; @@ -118,7 +113,6 @@ namespace Brizco.Domain.Mappers Type = p8.Type, Title = p8.Title, Description = p8.Description, - IsRelatedToShift = p8.IsRelatedToShift, IsRelatedToRole = p8.IsRelatedToRole, IsRelatedToPerson = p8.IsRelatedToPerson, IsDisposable = p8.IsDisposable, @@ -136,7 +130,6 @@ namespace Brizco.Domain.Mappers Type = p9.Type, Title = p9.Title, Description = p9.Description, - IsRelatedToShift = p9.IsRelatedToShift, IsRelatedToRole = p9.IsRelatedToRole, IsRelatedToPerson = p9.IsRelatedToPerson, IsDisposable = p9.IsDisposable, @@ -161,7 +154,6 @@ namespace Brizco.Domain.Mappers result.Type = p13.Type; result.Title = p13.Title; result.Description = p13.Description; - result.IsRelatedToShift = p13.IsRelatedToShift; result.IsRelatedToRole = p13.IsRelatedToRole; result.IsRelatedToPerson = p13.IsRelatedToPerson; result.IsDisposable = p13.IsDisposable; @@ -181,7 +173,6 @@ namespace Brizco.Domain.Mappers Type = p21.Type, Title = p21.Title, Description = p21.Description, - IsRelatedToShift = p21.IsRelatedToShift, IsRelatedToRole = p21.IsRelatedToRole, IsRelatedToPerson = p21.IsRelatedToPerson, IsDisposable = p21.IsDisposable, @@ -214,7 +205,6 @@ namespace Brizco.Domain.Mappers Type = p25.Type, Title = p25.Title, Description = p25.Description, - IsRelatedToShift = p25.IsRelatedToShift, IsRelatedToRole = p25.IsRelatedToRole, IsRelatedToPerson = p25.IsRelatedToPerson, IsDisposable = p25.IsDisposable, @@ -239,7 +229,6 @@ namespace Brizco.Domain.Mappers result.Type = p29.Type; result.Title = p29.Title; result.Description = p29.Description; - result.IsRelatedToShift = p29.IsRelatedToShift; result.IsRelatedToRole = p29.IsRelatedToRole; result.IsRelatedToPerson = p29.IsRelatedToPerson; result.IsDisposable = p29.IsDisposable; @@ -259,7 +248,6 @@ namespace Brizco.Domain.Mappers Type = p37.Type, Title = p37.Title, Description = p37.Description, - IsRelatedToShift = p37.IsRelatedToShift, IsRelatedToRole = p37.IsRelatedToRole, IsRelatedToPerson = p37.IsRelatedToPerson, IsDisposable = p37.IsDisposable, diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs index 7362425..c2784b5 100644 --- a/Brizco.Domain/MapsterRegister.cs +++ b/Brizco.Domain/MapsterRegister.cs @@ -9,7 +9,6 @@ public class MapsterRegister : IRegister public void Register(TypeAdapterConfig config) { config.NewConfig() - .Map("Days", org => org.Days.Select(d=>d.DayOfWeek).ToList()) .TwoWays(); diff --git a/Brizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs b/Brizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs index ee68e7f..44611e2 100644 --- a/Brizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs +++ b/Brizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs @@ -28,7 +28,6 @@ public class CreateActivityCommandHandler : IRequestHandler().Add(task); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs b/Brizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs index e488d64..1beedae 100644 --- a/Brizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs +++ b/Brizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs @@ -32,7 +32,6 @@ public class UpdateActivityCommandHandler : IRequestHandler shift.SetDay(d)); - _repositoryWrapper.SetRepository().Add(shift); await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.CommitAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs b/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs index 8249b54..c0e47ed 100644 --- a/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs +++ b/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs @@ -16,10 +16,6 @@ public class GetShiftPlansQueryHandler : IRequestHandler - { - s.Days = s.Days.OrderBy(d=>d).ToList(); - }); return shifts; } diff --git a/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs b/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs index 4ac5a6d..3c607c9 100644 --- a/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs +++ b/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Entities.Shift; - -namespace Brizco.Repository.Handlers.Shift; +namespace Brizco.Repository.Handlers.Shift; public class UpdateShiftCommandHandler : IRequestHandler { @@ -31,25 +29,6 @@ public class UpdateShiftCommandHandler : IRequestHandler() - .TableNoTracking.Where(sd => sd.ShiftId == request.Id) - .ToListAsync(cancellationToken); - - foreach (var shiftDay in shiftDays.Where(shiftDay => !request.DayOfWeeks.Contains(shiftDay.DayOfWeek))) - { - _repositoryWrapper.SetRepository() - .Delete(shiftDay); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); - } - - foreach (var dayOfWeek in request.DayOfWeeks) - { - var findDay = shiftDays.FirstOrDefault(sf => sf.DayOfWeek == dayOfWeek); - if (findDay != null) - shift.SetDay(dayOfWeek); - } - _repositoryWrapper.SetRepository() .Update(newShift); diff --git a/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs b/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs index a3fe947..c5320d4 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs @@ -19,7 +19,7 @@ public class CreateShiftPlanCommandHandler : IRequestHandler Handle(DeleteShiftPlanCommand request, CancellationToken cancellationToken) { var shiftPlan = await _repositoryWrapper.SetRepository() - .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id); + .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id,cancellationToken); if (shiftPlan == null) throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound); diff --git a/Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs b/Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs index 538fdf3..e7ca01b 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs @@ -24,7 +24,7 @@ public class UpdateShiftPlanCommandHandler : IRequestHandler().Add(task); await _repositoryWrapper.SaveChangesAsync(cancellationToken); return task.AdaptToLDto(); diff --git a/Brizco.Repository/Migrations/20231104072034_editShift.Designer.cs b/Brizco.Repository/Migrations/20231104072034_editShift.Designer.cs new file mode 100644 index 0000000..fbc1b91 --- /dev/null +++ b/Brizco.Repository/Migrations/20231104072034_editShift.Designer.cs @@ -0,0 +1,1079 @@ +// +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("20231104072034_editShift")] + partial class editShift + { + /// + 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.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.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("PlanDate") + .HasColumnType("timestamp without time zone"); + + 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("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.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("IsRelatedToPerson") + .HasColumnType("boolean"); + + b.Property("IsRelatedToRole") + .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("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.TaskRole", 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("RoleId") + .HasColumnType("uuid"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskRoles", "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.Task.TaskUser", 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("TaskId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TaskId"); + + b.HasIndex("UserId"); + + b.ToTable("TaskUsers", "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.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.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.ShiftPlan", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Plans") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + 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.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.TaskRole", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Roles") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Role"); + + 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.Task.TaskUser", b => + { + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Users") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Task"); + + b.Navigation("User"); + }); + + 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.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.Shift.Shift", b => + { + b.Navigation("Plans"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.Navigation("Days"); + + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Brizco.Repository/Migrations/20231104072034_editShift.cs b/Brizco.Repository/Migrations/20231104072034_editShift.cs new file mode 100644 index 0000000..205ac79 --- /dev/null +++ b/Brizco.Repository/Migrations/20231104072034_editShift.cs @@ -0,0 +1,95 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Brizco.Repository.Migrations +{ + /// + public partial class editShift : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ShiftDays", + schema: "public"); + + migrationBuilder.DropColumn( + name: "IsRelatedToShift", + schema: "public", + table: "Tasks"); + + migrationBuilder.DropColumn( + name: "EndAt", + schema: "public", + table: "ShiftPlans"); + + migrationBuilder.RenameColumn( + name: "StartAt", + schema: "public", + table: "ShiftPlans", + newName: "PlanDate"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "PlanDate", + schema: "public", + table: "ShiftPlans", + newName: "StartAt"); + + migrationBuilder.AddColumn( + name: "IsRelatedToShift", + schema: "public", + table: "Tasks", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "EndAt", + schema: "public", + table: "ShiftPlans", + type: "timestamp without time zone", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.CreateTable( + name: "ShiftDays", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ShiftId = table.Column(type: "uuid", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: false), + DayOfWeek = table.Column(type: "integer", 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_ShiftDays", x => x.Id); + table.ForeignKey( + name: "FK_ShiftDays_Shifts_ShiftId", + column: x => x.ShiftId, + principalSchema: "public", + principalTable: "Shifts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_ShiftDays_ShiftId", + schema: "public", + table: "ShiftDays", + column: "ShiftId"); + } + } +} diff --git a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs index e43712c..55c61fb 100644 --- a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -214,49 +214,6 @@ namespace Brizco.Repository.Migrations 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") @@ -270,9 +227,6 @@ namespace Brizco.Repository.Migrations .IsRequired() .HasColumnType("text"); - b.Property("EndAt") - .HasColumnType("timestamp without time zone"); - b.Property("IsRemoved") .HasColumnType("boolean"); @@ -283,6 +237,9 @@ namespace Brizco.Repository.Migrations .IsRequired() .HasColumnType("text"); + b.Property("PlanDate") + .HasColumnType("timestamp without time zone"); + b.Property("RemovedAt") .HasColumnType("timestamp without time zone"); @@ -293,9 +250,6 @@ namespace Brizco.Repository.Migrations b.Property("ShiftId") .HasColumnType("uuid"); - b.Property("StartAt") - .HasColumnType("timestamp without time zone"); - b.HasKey("Id"); b.HasIndex("ShiftId"); @@ -390,9 +344,6 @@ namespace Brizco.Repository.Migrations b.Property("IsRelatedToRole") .HasColumnType("boolean"); - b.Property("IsRelatedToShift") - .HasColumnType("boolean"); - b.Property("IsRemoved") .HasColumnType("boolean"); @@ -914,17 +865,6 @@ namespace Brizco.Repository.Migrations 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.Shift.Shift", "Shift") @@ -1112,8 +1052,6 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => { - b.Navigation("Days"); - b.Navigation("Plans"); });