diff --git a/Brizco.Api/Controllers/AuthController.cs b/Brizco.Api/Controllers/AuthController.cs index fd751f6..257f079 100644 --- a/Brizco.Api/Controllers/AuthController.cs +++ b/Brizco.Api/Controllers/AuthController.cs @@ -31,8 +31,16 @@ public class AuthController : ICarterModule .WithDisplayName("SignUp") .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) .HasApiVersion(1.0); + + group.MapGet("/check/{permission}/permission", CheckPermissionAsync) + .WithDisplayName("Check Permission") + .WithDescription("Check position permission by permission name , it will check current active shit and positions") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .HasApiVersion(1.0); } + private async Task CheckPermissionAsync([FromRoute] string permission, [FromServices] IAccountService accountService, CancellationToken cancellationToken) + => TypedResults.Ok(await accountService.CheckPositionPermission(permission, cancellationToken)); public async Task SignUpComplex([FromBody] SignUpRequestDto request, IAccountService accountService, CancellationToken cancellationToken) => TypedResults.Ok(await accountService.CompleteComplexSignUpAsync(request,cancellationToken)); diff --git a/Brizco.Api/Controllers/PositionController.cs b/Brizco.Api/Controllers/PositionController.cs index e177655..c706723 100644 --- a/Brizco.Api/Controllers/PositionController.cs +++ b/Brizco.Api/Controllers/PositionController.cs @@ -30,6 +30,7 @@ public class PositionController : ICarterModule group.MapDelete("{id}", Delete) .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManagePositions)) .HasApiVersion(1.0); + } // GET:Get All Entity diff --git a/Brizco.Core/CoreServices/Abstracts/IAccountService.cs b/Brizco.Core/CoreServices/Abstracts/IAccountService.cs index 76faf9e..b50509d 100644 --- a/Brizco.Core/CoreServices/Abstracts/IAccountService.cs +++ b/Brizco.Core/CoreServices/Abstracts/IAccountService.cs @@ -7,5 +7,6 @@ public interface IAccountService : IScopedDependency public Task GetVerifyCodeAsync(string phoneNumber); public Task ForgetPasswordAsync(string phoneNumber); public Task CheckMemberShipAsync(string phoneNumber); + public Task CheckPositionPermission(string permission,CancellationToken cancellationToken=default); public Task> CompleteComplexSignUpAsync(SignUpRequestDto requestDto, CancellationToken cancellationToken); } \ No newline at end of file diff --git a/Brizco.Core/CoreServices/AccountService.cs b/Brizco.Core/CoreServices/AccountService.cs index fab46a7..4d8c6d5 100644 --- a/Brizco.Core/CoreServices/AccountService.cs +++ b/Brizco.Core/CoreServices/AccountService.cs @@ -1,4 +1,8 @@ -namespace Brizco.Core.CoreServices; +using Brizco.Domain.Entities.Shift; +using System.Threading; +using NPOI.SS.Formula.Functions; + +namespace Brizco.Core.CoreServices; public class AccountService : IAccountService { @@ -64,6 +68,39 @@ public class AccountService : IAccountService return true; } + public async Task CheckPositionPermission(string permission, CancellationToken cancellationToken=default) + { + if (_currentUserService.UserId == null) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is wrong"); + if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is wrong"); + if (_currentUserService.ComplexId == null) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); + if(!Guid.TryParse(_currentUserService.ComplexId,out Guid complexId)) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); + + var query = from shiftPlan in _repositoryWrapper.SetRepository().Entities + join shift in _repositoryWrapper.SetRepository().Entities on shiftPlan.ShiftId equals shift.Id + where shiftPlan.PlanFor.Date == DateTime.Today.Date && shiftPlan.ComplexId == complexId && + shift.EndAt >= DateTime.Now.TimeOfDay && shift.StartAt <= DateTime.Now.TimeOfDay + select shiftPlan; + + var currentShiftPlan = await query.FirstOrDefaultAsync(cancellationToken); + if (currentShiftPlan == null) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "No active shift plan"); + + var userCurrentPositionPermissions = + await (from positionPermission in _repositoryWrapper.SetRepository().Entities + join position in _repositoryWrapper.SetRepository().Entities on positionPermission.PositionId + equals position.Id + join shiftPlaneUser in _repositoryWrapper.SetRepository().Entities on position.Id equals + shiftPlaneUser.PositionId + where shiftPlaneUser.ShiftPlanId == currentShiftPlan.Id && shiftPlaneUser.UserId == userId + select positionPermission).ToListAsync(cancellationToken); + + return userCurrentPositionPermissions.Any(f => f.Permission == permission); + } + public async Task GetVerifyCodeAsync(string phoneNumber) { var newPhoneNumber = StringExtensions.CheckPhoneNumber(phoneNumber); @@ -150,8 +187,7 @@ public class AccountService : IAccountService return await CompleteLogin(user, cancellationToken); } - - + private async Task> CompleteLogin(ApplicationUser user, CancellationToken cancellationToken) { AccessToken jwt; diff --git a/Brizco.Core/CoreServices/PageService.cs b/Brizco.Core/CoreServices/PageService.cs index 2504e5c..4a1621c 100644 --- a/Brizco.Core/CoreServices/PageService.cs +++ b/Brizco.Core/CoreServices/PageService.cs @@ -41,6 +41,7 @@ public class PageService : IPageService .Where(a => a.PlanFor.Date == DateTime.Today.Date && a.ComplexId == complexId) .Select(ShiftPlanMapper.ProjectToSDto) .ToListAsync(cancellationToken); + var names = new List(); names.AddRange(todayShiftPlans.SelectMany(sp => sp.Users).Select(s => s.UserFullName).ToList()); var page = new AppDashboardPageDto diff --git a/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs b/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs index 65a2671..a07c894 100644 --- a/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs @@ -1,9 +1,18 @@ namespace Brizco.Domain.CommandQueries.Commands; -public sealed record CreatePositionCommand(string Title, string Description, Guid SectionId) +public sealed record CreatePositionCommand( + string Title, + string Description, + Guid SectionId, + List Permissions) : IRequest; -public sealed record UpdatePositionCommand(Guid Id, string Title, string Description, Guid SectionId) +public sealed record UpdatePositionCommand( + Guid Id, + string Title, + string Description, + Guid SectionId, + List Permissions) : IRequest; public sealed record DeletePositionCommand(Guid Id) diff --git a/Brizco.Domain/Dtos/LargeDtos/PositionLDto.cs b/Brizco.Domain/Dtos/LargeDtos/PositionLDto.cs index 4c87d4c..9562efa 100644 --- a/Brizco.Domain/Dtos/LargeDtos/PositionLDto.cs +++ b/Brizco.Domain/Dtos/LargeDtos/PositionLDto.cs @@ -10,4 +10,5 @@ public class PositionLDto : BaseDto public Guid SectionId { get; set; } public string SectionName { get; set; } = string.Empty; + public List Permissions { get; set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs b/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs index 09ae82e..f7fcfe0 100644 --- a/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs +++ b/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs @@ -50,5 +50,13 @@ public partial class Position { return new Position(name, description, complexId, sectionId); } + + public void AddPermission(string permission) + => Permissions.Add(PositionPermission.Create(permission, Id)); } +public partial class PositionPermission +{ + public static PositionPermission Create(string permission, Guid positionId) + => new PositionPermission(permission, positionId); +} diff --git a/Brizco.Domain/Entities/Complex/Position.cs b/Brizco.Domain/Entities/Complex/Position.cs index 9866008..aa4cba4 100644 --- a/Brizco.Domain/Entities/Complex/Position.cs +++ b/Brizco.Domain/Entities/Complex/Position.cs @@ -17,12 +17,17 @@ public partial class Position : ApiEntity ComplexId = complexId; SectionId = sectionId; } + public string Name { get; internal set; } = string.Empty; public string Description { get; internal set; } = string.Empty; + + public Guid ComplexId { get; set; } public Complex? Complex { get; set; } public Guid SectionId { get; set; } public Section? Section { get; set; } + + public List Permissions { get; set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Complex/PositionPermission.cs b/Brizco.Domain/Entities/Complex/PositionPermission.cs new file mode 100644 index 0000000..6966380 --- /dev/null +++ b/Brizco.Domain/Entities/Complex/PositionPermission.cs @@ -0,0 +1,21 @@ +namespace Brizco.Domain.Entities.Complex; + +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class PositionPermission : ApiEntity +{ + public PositionPermission() + { + + } + public PositionPermission(string permission,Guid positionId) + { + PositionId = positionId; + Permission = permission; + } + public Guid PositionId { get; set; } + public Position? Position { get; set; } + public string Permission { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/PositionMapper.g.cs b/Brizco.Domain/Mappers/PositionMapper.g.cs index 8b63995..b46c354 100644 --- a/Brizco.Domain/Mappers/PositionMapper.g.cs +++ b/Brizco.Domain/Mappers/PositionMapper.g.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using System.Linq.Expressions; using Brizco.Domain.Dtos.LargeDtos; using Brizco.Domain.Dtos.SmallDtos; @@ -93,81 +95,171 @@ namespace Brizco.Domain.Mappers Name = p9.SectionName, Id = p9.SectionId }, + Permissions = funcMain1(p9.Permissions), Id = p9.Id }; } - public static Position AdaptTo(this PositionLDto p10, Position p11) + 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.Permissions = funcMain4(p11.Permissions, result.Permissions); + result.Id = p11.Id; + return result; + + } + public static PositionLDto AdaptToLDto(this Position p19) + { + return p19 == null ? null : new PositionLDto() + { + Name = p19.Name, + Description = p19.Description, + ComplexId = p19.ComplexId, + SectionId = p19.SectionId, + SectionName = p19.Section != null ? p19.Section.Name : string.Empty, + Permissions = funcMain5(p19.Permissions.Select(funcMain6)), + Id = p19.Id + }; + } + public static PositionLDto AdaptTo(this Position p21, PositionLDto p22) + { + if (p21 == null) + { + return null; + } + PositionLDto result = p22 ?? new PositionLDto(); + + result.Name = p21.Name; + result.Description = p21.Description; + result.ComplexId = p21.ComplexId; + result.SectionId = p21.SectionId; + result.SectionName = p21.Section != null ? p21.Section.Name : string.Empty; + result.Permissions = funcMain7(p21.Permissions.Select(funcMain6), result.Permissions); + result.Id = p21.Id; + return result; + + } + public static Expression> ProjectToLDto => p25 => new PositionLDto() + { + Name = p25.Name, + Description = p25.Description, + ComplexId = p25.ComplexId, + SectionId = p25.SectionId, + SectionName = p25.Section != null ? p25.Section.Name : string.Empty, + Permissions = (List)p25.Permissions.Select(p => p.Permission), + Id = p25.Id + }; + + private static List funcMain1(List p10) { if (p10 == null) { return null; } - Position result = p11 ?? new Position(); + List result = new List(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; + int i = 0; + int len = p10.Count; + + while (i < len) + { + string item = p10[i]; + result.Add(item == null ? null : (PositionPermission)Convert.ChangeType((object)item, typeof(PositionPermission))); + i++; + } return result; } - public static PositionLDto AdaptToLDto(this Position p16) + + private static Complex funcMain2(Never p13, Complex p14, PositionLDto p11) { - return p16 == null ? null : new PositionLDto() - { - Name = p16.Name, - Description = p16.Description, - ComplexId = p16.ComplexId, - SectionId = p16.SectionId, - SectionName = p16.Section != null ? p16.Section.Name : string.Empty, - Id = p16.Id - }; + Complex result = p14 ?? new Complex(); + + result.Id = p11.ComplexId; + return result; + } - public static PositionLDto AdaptTo(this Position p17, PositionLDto p18) + + private static Section funcMain3(Never p15, Section p16, PositionLDto p11) + { + 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) { return null; } - PositionLDto result = p18 ?? new PositionLDto(); + List result = new List(p17.Count); - result.Name = p17.Name; - result.Description = p17.Description; - result.ComplexId = p17.ComplexId; - result.SectionId = p17.SectionId; - result.SectionName = p17.Section != null ? p17.Section.Name : string.Empty; - result.Id = p17.Id; - return result; + int i = 0; + int len = p17.Count; - } - public static Expression> ProjectToLDto => p19 => new PositionLDto() - { - Name = p19.Name, - Description = p19.Description, - ComplexId = p19.ComplexId, - SectionId = p19.SectionId, - SectionName = p19.Section != null ? p19.Section.Name : string.Empty, - Id = p19.Id - }; - - private static Complex funcMain1(Never p12, Complex p13, PositionLDto p10) - { - Complex result = p13 ?? new Complex(); - - result.Id = p10.ComplexId; + while (i < len) + { + string item = p17[i]; + result.Add(item == null ? null : (PositionPermission)Convert.ChangeType((object)item, typeof(PositionPermission))); + i++; + } return result; } - private static Section funcMain2(Never p14, Section p15, PositionLDto p10) + private static List funcMain5(IEnumerable p20) { - Section result = p15 ?? new Section(); + if (p20 == null) + { + return null; + } + List result = new List(); - result.Name = p10.SectionName; - result.Id = p10.SectionId; + IEnumerator enumerator = p20.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } + return result; + + } + + private static string funcMain6(PositionPermission p) + { + return p.Permission; + } + + private static List funcMain7(IEnumerable p23, List p24) + { + if (p23 == null) + { + return null; + } + List result = new List(); + + IEnumerator enumerator = p23.GetEnumerator(); + + while (enumerator.MoveNext()) + { + string item = enumerator.Current; + result.Add(item); + } return result; } diff --git a/Brizco.Domain/Mappers/PositionPermissionMapper.g.cs b/Brizco.Domain/Mappers/PositionPermissionMapper.g.cs new file mode 100644 index 0000000..62fe05d --- /dev/null +++ b/Brizco.Domain/Mappers/PositionPermissionMapper.g.cs @@ -0,0 +1,6 @@ +namespace Brizco.Domain.Mappers +{ + public static partial class PositionPermissionMapper + { + } +} \ No newline at end of file diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs index 08ce055..8af944b 100644 --- a/Brizco.Domain/MapsterRegister.cs +++ b/Brizco.Domain/MapsterRegister.cs @@ -64,6 +64,7 @@ public class MapsterRegister : IRegister config.NewConfig() .Map("SectionName", org => org.Section != null ? org.Section.Name : string.Empty) + .Map(o=>o.Permissions, org => org.Permissions.Select(p=>p.Permission)) .TwoWays(); config.NewConfig() diff --git a/Brizco.Repository/Handlers/Position/CreatePositionCommandHandler.cs b/Brizco.Repository/Handlers/Position/CreatePositionCommandHandler.cs index d0662da..98a473e 100644 --- a/Brizco.Repository/Handlers/Position/CreatePositionCommandHandler.cs +++ b/Brizco.Repository/Handlers/Position/CreatePositionCommandHandler.cs @@ -27,8 +27,7 @@ public class CreatePositionCommandHandler : IRequestHandlerentity.AddPermission(f)); _repositoryWrapper.SetRepository().Add(entity); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs b/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs index 41c3f9e..b3b72f8 100644 --- a/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs +++ b/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs @@ -13,9 +13,9 @@ public class UpdatePositionCommandHandler : IRequestHandler Handle(UpdatePositionCommand request, CancellationToken cancellationToken) { - var shift = await _repositoryWrapper.SetRepository() + var ent = await _repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); - if (shift == null) + if (ent == null) throw new AppException("Postion not found", ApiResultStatusCode.NotFound); if (_currentUserService.ComplexId == null) @@ -28,6 +28,23 @@ public class UpdatePositionCommandHandler : IRequestHandler() + .TableNoTracking + .Where(f => f.PositionId == ent.Id) + .ToListAsync(cancellationToken); + + foreach (var permissionDb in permissionsDb.Where(p=>!request.Permissions.Contains(p.Permission))) + { + _repositoryWrapper.SetRepository() + .Delete(permissionDb); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + + foreach (var permission in request.Permissions.Where(p => !permissionsDb.Select(d => d.Permission).Contains(p))) + newPosition.AddPermission(permission); _repositoryWrapper.SetRepository() .Update(newPosition); diff --git a/Brizco.Repository/Migrations/20240602074316_AddPositionPermission.Designer.cs b/Brizco.Repository/Migrations/20240602074316_AddPositionPermission.Designer.cs new file mode 100644 index 0000000..40b345e --- /dev/null +++ b/Brizco.Repository/Migrations/20240602074316_AddPositionPermission.Designer.cs @@ -0,0 +1,1523 @@ +// +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("20240602074316_AddPositionPermission")] + partial class AddPositionPermission + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.4") + .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.PositionPermission", 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("Permission") + .IsRequired() + .HasColumnType("text"); + + b.Property("PositionId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("PositionId"); + + b.ToTable("PositionPermissions", "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("CompleteDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("CompletePercent") + .HasColumnType("integer"); + + b.Property("ComplexId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsCompleted") + .HasColumnType("boolean"); + + 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.Property("SupervisorId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("RoutineId"); + + b.HasIndex("ShiftId"); + + b.HasIndex("SupervisorId"); + + b.ToTable("ShiftPlans", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .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() + .HasMaxLength(8) + .HasColumnType("character varying(8)"); + + b.Property("HasDisposed") + .HasColumnType("boolean"); + + b.Property("IsActivity") + .HasColumnType("boolean"); + + b.Property("IsDisposable") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .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("ShiftPlanId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UnDoneReason") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasIndex("ShiftPlanId"); + + 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); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + 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); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + 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); + + b.HasOne("Brizco.Domain.Entities.Complex.Section", "Section") + .WithMany("Positions") + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Complex"); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.PositionPermission", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany("Permissions") + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Position"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict); + + 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); + + 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); + + 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); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany() + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Plans") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "Supervisor") + .WithMany() + .HasForeignKey("SupervisorId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Complex"); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + + b.Navigation("Supervisor"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + .WithMany("Users") + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + 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); + + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Routines") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + 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); + + 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); + + 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); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Positions") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict); + + 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); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Routines") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict); + + 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); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Shifts") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict); + + 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); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + .WithMany() + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ShiftPlan"); + + 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("Permissions"); + }); + + 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/20240602074316_AddPositionPermission.cs b/Brizco.Repository/Migrations/20240602074316_AddPositionPermission.cs new file mode 100644 index 0000000..c50782e --- /dev/null +++ b/Brizco.Repository/Migrations/20240602074316_AddPositionPermission.cs @@ -0,0 +1,1017 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Brizco.Repository.Migrations +{ + /// + public partial class AddPositionPermission : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "TaskShifts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "TaskShifts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "TaskShifts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Tasks", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Tasks", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Tasks", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "TaskRoutines", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "TaskRoutines", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "TaskRoutines", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "TaskPositions", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "TaskPositions", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "TaskPositions", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "TaskDays", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "TaskDays", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "TaskDays", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Shifts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Shifts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Shifts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ShiftRoutines", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ShiftRoutines", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ShiftRoutines", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ShiftPlanUsers", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ShiftPlanUsers", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ShiftPlanUsers", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ShiftPlans", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ShiftPlans", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ShiftPlans", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ShiftDays", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ShiftDays", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ShiftDays", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Sections", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Sections", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Sections", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Routines", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Routines", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Routines", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Positions", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Positions", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Positions", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ComplexUsers", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ComplexUsers", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ComplexUsers", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ComplexUserRoles", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ComplexUserRoles", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ComplexUserRoles", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Complexes", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Complexes", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Complexes", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.CreateTable( + name: "PositionPermissions", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + PositionId = table.Column(type: "uuid", nullable: false), + Permission = table.Column(type: "text", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", 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), + RemovedBy = table.Column(type: "text", nullable: false), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PositionPermissions", x => x.Id); + table.ForeignKey( + name: "FK_PositionPermissions_Positions_PositionId", + column: x => x.PositionId, + principalSchema: "public", + principalTable: "Positions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_PositionPermissions_PositionId", + schema: "public", + table: "PositionPermissions", + column: "PositionId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "PositionPermissions", + schema: "public"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "TaskShifts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "TaskShifts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "TaskShifts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Tasks", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Tasks", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Tasks", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "TaskRoutines", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "TaskRoutines", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "TaskRoutines", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "TaskPositions", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "TaskPositions", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "TaskPositions", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "TaskDays", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "TaskDays", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "TaskDays", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Shifts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Shifts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Shifts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ShiftRoutines", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ShiftRoutines", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ShiftRoutines", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ShiftPlanUsers", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ShiftPlanUsers", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ShiftPlanUsers", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ShiftPlans", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ShiftPlans", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ShiftPlans", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ShiftDays", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ShiftDays", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ShiftDays", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Sections", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Sections", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Sections", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Routines", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Routines", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Routines", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Positions", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Positions", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Positions", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ComplexUsers", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ComplexUsers", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ComplexUsers", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ComplexUserRoles", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ComplexUserRoles", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ComplexUserRoles", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Complexes", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Complexes", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Complexes", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + } + } +} diff --git a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs index 7bb2067..cc7dcd1 100644 --- a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -37,6 +37,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -46,6 +47,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") + .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -56,6 +58,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") + .IsRequired() .HasColumnType("text"); b.Property("SupportPhone") @@ -80,6 +83,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -89,12 +93,14 @@ namespace Brizco.Repository.Migrations .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") @@ -122,6 +128,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -131,12 +138,14 @@ namespace Brizco.Repository.Migrations .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") @@ -164,6 +173,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -177,6 +187,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") + .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -187,6 +198,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") + .IsRequired() .HasColumnType("text"); b.Property("SectionId") @@ -201,6 +213,50 @@ namespace Brizco.Repository.Migrations b.ToTable("Positions", "public"); }); + modelBuilder.Entity("Brizco.Domain.Entities.Complex.PositionPermission", 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("Permission") + .IsRequired() + .HasColumnType("text"); + + b.Property("PositionId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("PositionId"); + + b.ToTable("PositionPermissions", "public"); + }); + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => { b.Property("Id") @@ -214,6 +270,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -227,6 +284,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") + .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -237,6 +295,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") + .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -259,6 +318,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -272,6 +332,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") + .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -282,6 +343,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") + .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -304,6 +366,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -320,12 +383,14 @@ namespace Brizco.Repository.Migrations .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") @@ -352,6 +417,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("DayOfWeek") @@ -364,12 +430,14 @@ namespace Brizco.Repository.Migrations .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") @@ -402,6 +470,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("IsCompleted") @@ -414,6 +483,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") + .IsRequired() .HasColumnType("text"); b.Property("PlanFor") @@ -423,6 +493,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") + .IsRequired() .HasColumnType("text"); b.Property("RoutineId") @@ -457,6 +528,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -466,6 +538,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") + .IsRequired() .HasColumnType("text"); b.Property("PositionId") @@ -475,6 +548,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") + .IsRequired() .HasColumnType("text"); b.Property("ShiftPlanId") @@ -504,6 +578,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -513,12 +588,14 @@ namespace Brizco.Repository.Migrations .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") @@ -555,6 +632,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -582,12 +660,14 @@ namespace Brizco.Repository.Migrations .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") @@ -624,6 +704,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("DayOfWeek") @@ -636,12 +717,14 @@ namespace Brizco.Repository.Migrations .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") @@ -664,6 +747,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -673,6 +757,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") + .IsRequired() .HasColumnType("text"); b.Property("PositionId") @@ -682,6 +767,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") + .IsRequired() .HasColumnType("text"); b.Property("TaskId") @@ -706,6 +792,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -715,12 +802,14 @@ namespace Brizco.Repository.Migrations .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") @@ -748,6 +837,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") + .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -757,12 +847,14 @@ namespace Brizco.Repository.Migrations .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") @@ -1101,6 +1193,16 @@ namespace Brizco.Repository.Migrations b.Navigation("Section"); }); + modelBuilder.Entity("Brizco.Domain.Entities.Complex.PositionPermission", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany("Permissions") + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Position"); + }); + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => { b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") @@ -1371,6 +1473,11 @@ namespace Brizco.Repository.Migrations b.Navigation("Roles"); }); + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b => + { + b.Navigation("Permissions"); + }); + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => { b.Navigation("Positions");