diff --git a/AccountManagement.Application.Contracts/SubAccount/CreateSubAccount.cs b/AccountManagement.Application.Contracts/SubAccount/CreateSubAccount.cs index 9f82aa3c..e651e48f 100644 --- a/AccountManagement.Application.Contracts/SubAccount/CreateSubAccount.cs +++ b/AccountManagement.Application.Contracts/SubAccount/CreateSubAccount.cs @@ -15,6 +15,6 @@ namespace AccountManagement.Application.Contracts.SubAccount public string PhoneNumber { get; set; } public string Username { get; set; } public string ProfilePhoto { get; set; } - public List WorkshopIds { get; set; } + //public List WorkshopIds { get; set; } } } diff --git a/AccountManagement.Application.Contracts/SubAccount/CreateSubAccountRole.cs b/AccountManagement.Application.Contracts/SubAccount/CreateSubAccountRole.cs index 2e7a9035..c17236b4 100644 --- a/AccountManagement.Application.Contracts/SubAccount/CreateSubAccountRole.cs +++ b/AccountManagement.Application.Contracts/SubAccount/CreateSubAccountRole.cs @@ -8,5 +8,6 @@ namespace AccountManagement.Application.Contracts.SubAccount public string Title { get; set; } public long AccountId { get; set; } public List Permissions { get; set; } + public List WorkshopIds { get; set; } } } diff --git a/AccountManagement.Application.Contracts/SubAccount/EditSubAccount.cs b/AccountManagement.Application.Contracts/SubAccount/EditSubAccount.cs index f2b9eeda..76e6dad1 100644 --- a/AccountManagement.Application.Contracts/SubAccount/EditSubAccount.cs +++ b/AccountManagement.Application.Contracts/SubAccount/EditSubAccount.cs @@ -13,7 +13,7 @@ namespace AccountManagement.Application.Contracts.SubAccount public string PhoneNumber { get; set; } public string RePassword { get; set; } public long SubAccountRoleId { get; set; } - public List WorkshopIds { get; set; } + //public List WorkshopIds { get; set; } } diff --git a/AccountManagement.Application.Contracts/SubAccount/SubAccountRoleViewModel.cs b/AccountManagement.Application.Contracts/SubAccount/SubAccountRoleViewModel.cs index 2b1ad82e..3b3c4934 100644 --- a/AccountManagement.Application.Contracts/SubAccount/SubAccountRoleViewModel.cs +++ b/AccountManagement.Application.Contracts/SubAccount/SubAccountRoleViewModel.cs @@ -7,5 +7,6 @@ namespace AccountManagement.Application.Contracts.SubAccount public long Id { get; set; } public string Title { get; set; } public List Permissions { get; set; } + public List WorkshopIds { get; set; } } } diff --git a/AccountManagement.Application/SubAccountApplication.cs b/AccountManagement.Application/SubAccountApplication.cs index 2a005564..6651c598 100644 --- a/AccountManagement.Application/SubAccountApplication.cs +++ b/AccountManagement.Application/SubAccountApplication.cs @@ -113,12 +113,12 @@ namespace AccountManagement.Application if (cmd.PhoneNumber.Length != 11) return op.Failed("شماره تلفن همراه نامعتبر است"); - if (!cmd.WorkshopIds.Any()) - return op.Failed("حداقل یک کارگاه را انتخاب کنید"); + //if (!cmd.WorkshopIds.Any()) + // return op.Failed("حداقل یک کارگاه را انتخاب کنید"); - if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x))) - return op.Failed("خطای سیستمی"); + //if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x))) + // return op.Failed("خطای سیستمی"); if (cmd.SubAccountRoleId == 0 || !_subAccountRoleRepository.Exists(x => cmd.SubAccountRoleId == x.id)) @@ -131,6 +131,10 @@ namespace AccountManagement.Application _cameraAccountRepository.Exists(x => x.Username == cmd.Username)) return op.Failed("نام کاربری نمی تواند تکراری باشد"); + var role = _subAccountRoleRepository.Get(cmd.SubAccountRoleId); + var workshopId = role.RoleWorkshops.Select(x => x.WorkshopId).ToList(); + + var entity = new SubAccount(cmd.AccountId, cmd.SubAccountRoleId, cmd.NationalCode, cmd.FName, cmd.LName, cmd.PhoneNumber, cmd.Username, _passwordHasher.Hash(cmd.Password), cmd.ProfilePhoto); @@ -142,7 +146,7 @@ namespace AccountManagement.Application _subAccountRepository.SaveChanges(); - var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, entity.id)); + var workshops = workshopId.Select(x => new WorkshopSubAccount(x, entity.id)); foreach (var w in workshops) _workshopSubAccountRepository.Create(w); @@ -175,22 +179,22 @@ namespace AccountManagement.Application - if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x))) - return op.Failed("خطای سیستمی"); + //if (!cmd.WorkshopIds.All(x => accountWorkshopsList.Contains(x))) + // return op.Failed("خطای سیستمی"); if (cmd.SubAccountRoleId == 0 || !_subAccountRoleRepository.Exists(x => cmd.SubAccountRoleId == x.id)) return op.Failed("نقش مورد نظر وجود ندارد"); - var workshopSubAccounts = _workshopSubAccountRepository.GetWorkshopsSubAccountEntityBySubAccountId(entity.id); - foreach (var workshopSubAccount in workshopSubAccounts) - _workshopSubAccountRepository.Remove(workshopSubAccount); + //var workshopSubAccounts = _workshopSubAccountRepository.GetWorkshopsSubAccountEntityBySubAccountId(entity.id); + //foreach (var workshopSubAccount in workshopSubAccounts) + // _workshopSubAccountRepository.Remove(workshopSubAccount); - var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, entity.id)); + //var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, entity.id)); - foreach (var w in workshops) - _workshopSubAccountRepository.Create(w); + //foreach (var w in workshops) + // _workshopSubAccountRepository.Create(w); entity.Edit(cmd.SubAccountRoleId, cmd.NationalCode, cmd.FName, cmd.LName, cmd.ProfilePhoto); _workshopSubAccountRepository.SaveChanges(); @@ -227,7 +231,8 @@ namespace AccountManagement.Application { Id = entity.id, Title = entity.Title, - Permissions = entity.RolePermissions.Select(x => x.PermissionCode).ToList() + Permissions = entity.RolePermissions.Select(x => x.PermissionCode).ToList(), + WorkshopIds = entity.RoleWorkshops.Select(x=>x.WorkshopId).ToList() }; } @@ -241,7 +246,7 @@ namespace AccountManagement.Application OperationResult op = new(); if (_subAccountRoleRepository.Exists(x => x.AccountId == command.AccountId && x.Title.Trim() == command.Title.Trim())) return op.Failed("یک نقش با این عنوان وجود دارد"); - var role = new SubAccountRole(command.Title, command.Permissions, command.AccountId); + var role = new SubAccountRole(command.Title, command.Permissions, command.AccountId,command.WorkshopIds); _subAccountRoleRepository.Create(role); _subAccountRoleRepository.SaveChanges(); return op.Succcedded(role.id); @@ -254,8 +259,24 @@ namespace AccountManagement.Application var entity = _subAccountRoleRepository.Get(cmd.Id); if (entity == null) return op.Failed(ApplicationMessages.RecordNotFound); - entity.Edit(cmd.Title, cmd.Permissions); - _subAccountRoleRepository.SaveChanges(); + entity.Edit(cmd.Title, cmd.Permissions,cmd.WorkshopIds); + + var subAccountRoles = _subAccountRepository.GetBySubAccountRole(cmd.Id); + + foreach (var subAccount in subAccountRoles) + { + var workshopSubAccounts = _workshopSubAccountRepository.GetWorkshopsSubAccountEntityBySubAccountId(subAccount.id); + foreach (var workshopSubAccount in workshopSubAccounts) + _workshopSubAccountRepository.Remove(workshopSubAccount); + + + var workshops = cmd.WorkshopIds.Select(x => new WorkshopSubAccount(x, subAccount.id)); + + foreach (var w in workshops) + _workshopSubAccountRepository.Create(w); + } + + _subAccountRoleRepository.SaveChanges(); return op.Succcedded(); } public OperationResult AssignRoleToSubAccount(AssignSubAccountRole command) diff --git a/AccountManagement.Domain/SubAccountAgg/ISubAccountRepository.cs b/AccountManagement.Domain/SubAccountAgg/ISubAccountRepository.cs index eba9137e..f5779eb2 100644 --- a/AccountManagement.Domain/SubAccountAgg/ISubAccountRepository.cs +++ b/AccountManagement.Domain/SubAccountAgg/ISubAccountRepository.cs @@ -2,6 +2,7 @@ using _0_Framework.Domain; using AccountManagement.Application.Contracts.SubAccount; using System.Collections.Generic; +using System.Collections.Specialized; namespace AccountManagement.Domain.SubAccountAgg { @@ -13,5 +14,6 @@ namespace AccountManagement.Domain.SubAccountAgg SubAccount GetDetails(long subAccountId); SubAccount GetBy(string commandUsername); SubAccountViewModel GetByVerifyCodeAndPhoneNumber(string code, string phone); + List GetBySubAccountRole(long subAccountRoleId); } } diff --git a/AccountManagement.Domain/SubAccountRoleAgg/SubAccountRole.cs b/AccountManagement.Domain/SubAccountRoleAgg/SubAccountRole.cs index e7267447..69acbfd6 100644 --- a/AccountManagement.Domain/SubAccountRoleAgg/SubAccountRole.cs +++ b/AccountManagement.Domain/SubAccountRoleAgg/SubAccountRole.cs @@ -13,17 +13,21 @@ namespace AccountManagement.Domain.SubAccountRoleAgg public List RolePermissions { get; private set; } public List SubAccounts { get; private set; } + public List RoleWorkshops { get; set; } private SubAccountRole() { } - public SubAccountRole(string title, List permissions, long accountId) + public SubAccountRole(string title, List permissions, long accountId, List workshopIds) { Title = title; RolePermissions = permissions.Select(x => new SubAccountRolePermission(x, id)).ToList(); AccountId = accountId; + RoleWorkshops = workshopIds.Select(x => new SubAccountRoleWorkshop(x, id)).ToList(); + } + public void ChangeTitle(string title) { Title = title; @@ -32,10 +36,12 @@ namespace AccountManagement.Domain.SubAccountRoleAgg { RolePermissions.AddRange(permissionIds.Select(x => new SubAccountRolePermission(x, id))); } - public void Edit(string title, List permissions) + public void Edit(string title, List permissions,List workshopIds) { Title = title; RolePermissions = permissions.Select(x => new SubAccountRolePermission(x, id)).ToList(); - } - } + RoleWorkshops = workshopIds.Select(x => new SubAccountRoleWorkshop(x, id)).ToList(); + + } + } } \ No newline at end of file diff --git a/AccountManagement.Domain/SubAccountRoleAgg/SubAccountRoleWorkshop.cs b/AccountManagement.Domain/SubAccountRoleAgg/SubAccountRoleWorkshop.cs new file mode 100644 index 00000000..1286cf4d --- /dev/null +++ b/AccountManagement.Domain/SubAccountRoleAgg/SubAccountRoleWorkshop.cs @@ -0,0 +1,16 @@ +using _0_Framework.Domain; + +namespace AccountManagement.Domain.SubAccountRoleAgg; + +public class SubAccountRoleWorkshop:EntityBase +{ + public SubAccountRoleWorkshop(long workshopId, long subAccountId) + { + WorkshopId = workshopId; + SubAccountId = subAccountId; + } + + public long WorkshopId { get; set; } + public long SubAccountId { get; set; } + public SubAccountRole SubAccountRole { get; set; } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/SubAccountRoleMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/SubAccountRoleMapping.cs index 6058d7e1..66aae03f 100644 --- a/AccountMangement.Infrastructure.EFCore/Mappings/SubAccountRoleMapping.cs +++ b/AccountMangement.Infrastructure.EFCore/Mappings/SubAccountRoleMapping.cs @@ -21,6 +21,10 @@ namespace AccountMangement.Infrastructure.EFCore.Mappings opt.WithOwner(x => x.SubAccountRole); }); + builder.OwnsMany(x => x.RoleWorkshops, roleWorkshop => + { + roleWorkshop.WithOwner(x => x.SubAccountRole).HasForeignKey(x => x.SubAccountId); + }); } } } diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20250530133036_add workshop to subAccountRole.Designer.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20250530133036_add workshop to subAccountRole.Designer.cs new file mode 100644 index 00000000..dc590baa --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20250530133036_add workshop to subAccountRole.Designer.cs @@ -0,0 +1,1303 @@ +// +using System; +using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + [DbContext(typeof(AccountContext))] + [Migration("20250530133036_add workshop to subAccountRole")] + partial class addworkshoptosubAccountRole + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAreaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ClientAriaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Fullname") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActiveString") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PositionId") + .HasMaxLength(10) + .HasColumnType("bigint"); + + b.Property("PositionIsActive") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("id"); + + b.HasIndex("PositionId"); + + b.HasIndex("RoleId"); + + b.ToTable("Accounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountLeftWorkAgg.AccountLeftWork", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LeftWorkGr") + .HasColumnType("datetime2"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("StartWorkGr") + .HasColumnType("datetime2"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("AccountLeftWork", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveString") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("AdminResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.Property("AdminResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("AdminResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("AdminResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("AssignedId") + .HasColumnType("bigint"); + + b.Property("AssignedName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("AssignedPositionValue") + .HasColumnType("int"); + + b.Property("AssignerId") + .HasColumnType("bigint"); + + b.Property("AssignerPositionValue") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("FirstTimeCreation") + .HasColumnType("bit"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("IsDoneRequest") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.HasKey("id"); + + b.HasIndex("TaskId"); + + b.ToTable("Assigns", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveSting") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Mobile") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.Property("WorkshopName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("CameraAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("ClientResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.Property("ClientResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("ClientResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("ClientResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Category") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Path") + .HasColumnType("ntext"); + + b.Property("ServiceName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("Medias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.PositionAgg.Position", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PositionName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PositionValue") + .HasMaxLength(2) + .HasColumnType("int"); + + b.HasKey("id"); + + b.ToTable("Positions", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountAgg.SubAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("FName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("LName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PhoneNumber") + .IsRequired() + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("SubAccountRoleId") + .HasColumnType("bigint"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.HasIndex("SubAccountRoleId"); + + b.ToTable("SubAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle1Agg.SubAccountPermissionSubtitle1", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Code") + .HasMaxLength(15) + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("id"); + + b.ToTable("SubAccountPermissionSubtitle1", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle2Agg.SubAccountPermissionSubtitle2", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Code") + .HasMaxLength(15) + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("id"); + + b.HasIndex("ParentId"); + + b.ToTable("SubAccountPermissionSubtitle2", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle3Agg.SubAccountPermissionSubtitle3", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Code") + .HasMaxLength(15) + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("id"); + + b.HasIndex("ParentId"); + + b.ToTable("SubAccountPermissionSubtitle3", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle4Agg.SubAccountPermissionSubtitle4", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Code") + .HasMaxLength(15) + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("id"); + + b.HasIndex("ParentId"); + + b.ToTable("SubAccountPermissionSubtitle4", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Title") + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("id"); + + b.ToTable("SubAccountRoles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("IsActiveString") + .HasMaxLength(7) + .HasColumnType("nvarchar(7)"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("StartTaskDate") + .HasColumnType("datetime2"); + + b.Property("TaskScheduleId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("TaskScheduleId"); + + b.ToTable("TasksManager", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.Property("MediaId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("MediaId", "TaskId"); + + b.HasIndex("TaskId"); + + b.ToTable("TasksMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Message") + .HasColumnType("ntext"); + + b.Property("RequestedDateFa") + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.Property("TypeOfMessage") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("id"); + + b.HasIndex("AssignId"); + + b.ToTable("TaskMessages", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageItemsAgg.TaskMessageItems", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ReceiverAccountId") + .HasColumnType("bigint"); + + b.Property("SenderAccountId") + .HasColumnType("bigint"); + + b.Property("TaskMessageId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskMessageId"); + + b.ToTable("TaskMessageItems", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Count") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActive") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("LastEndTaskDate") + .HasColumnType("datetime2"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("UnitNumber") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("UnitType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("TaskSchedules", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TaskSubjects", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAccessAccountAgg.TicketAccessAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.HasKey("id"); + + b.ToTable("TicketAccessAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(155) + .HasColumnType("nvarchar(155)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("Status") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("SubAccountSenderId") + .HasColumnType("bigint"); + + b.Property("TicketNumber") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("TicketType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("TicketId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("TicketMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.HasOne("AccountManagement.Domain.PositionAgg.Position", "Position") + .WithMany("Accounts") + .HasForeignKey("PositionId"); + + b.HasOne("AccountManagement.Domain.RoleAgg.Role", "Role") + .WithMany("Accounts") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountLeftWorkAgg.AccountLeftWork", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("AccountLeftWorkList") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("AdminResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.AdminResponseAgg.AdminResponse", "AdminResponse") + .WithMany("AdminResponseMedias") + .HasForeignKey("AdminResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("AdminResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AdminResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Task") + .WithMany("Assigns") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("CameraAccounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("ClientResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.ClientResponseAgg.ClientResponse", "ClientResponse") + .WithMany("ClientResponseMedias") + .HasForeignKey("ClientResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("ClientResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ClientResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("RolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountAgg.SubAccount", b => + { + b.HasOne("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", "SubAccountRole") + .WithMany("SubAccounts") + .HasForeignKey("SubAccountRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SubAccountRole"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle2Agg.SubAccountPermissionSubtitle2", b => + { + b.HasOne("AccountManagement.Domain.SubAccountPermissionSubtitle1Agg.SubAccountPermissionSubtitle1", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle3Agg.SubAccountPermissionSubtitle3", b => + { + b.HasOne("AccountManagement.Domain.SubAccountPermissionSubtitle2Agg.SubAccountPermissionSubtitle2", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle4Agg.SubAccountPermissionSubtitle4", b => + { + b.HasOne("AccountManagement.Domain.SubAccountPermissionSubtitle3Agg.SubAccountPermissionSubtitle3", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", b => + { + b.OwnsMany("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRoleWorkshop", "RoleWorkshops", b1 => + { + b1.Property("SubAccountId") + .HasColumnType("bigint"); + + b1.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("id")); + + b1.Property("CreationDate") + .HasColumnType("datetime2"); + + b1.Property("WorkshopId") + .HasColumnType("bigint"); + + b1.HasKey("SubAccountId", "id"); + + b1.ToTable("SubAccountRoleWorkshop"); + + b1.WithOwner("SubAccountRole") + .HasForeignKey("SubAccountId"); + + b1.Navigation("SubAccountRole"); + }); + + b.OwnsMany("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRolePermission", "RolePermissions", b1 => + { + b1.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("id")); + + b1.Property("PermissionCode") + .HasColumnType("int"); + + b1.Property("SubAccountRoleId") + .HasColumnType("bigint"); + + b1.HasKey("id"); + + b1.HasIndex("SubAccountRoleId"); + + b1.ToTable("SubAccountRolePermissions", (string)null); + + b1.WithOwner("SubAccountRole") + .HasForeignKey("SubAccountRoleId"); + + b1.Navigation("SubAccountRole"); + }); + + b.Navigation("RolePermissions"); + + b.Navigation("RoleWorkshops"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.HasOne("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", "TaskSchedule") + .WithMany("TasksList") + .HasForeignKey("TaskScheduleId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("TaskSchedule"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TaskMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Tasks") + .WithMany("TaskMedias") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.HasOne("AccountManagement.Domain.AssignAgg.Assign", "Assign") + .WithMany("TaskMessageList") + .HasForeignKey("AssignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Assign"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageItemsAgg.TaskMessageItems", b => + { + b.HasOne("AccountManagement.Domain.TaskMessageAgg.TaskMessage", "TaskMessage") + .WithMany("TaskMessageItemsList") + .HasForeignKey("TaskMessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TaskMessage"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TicketMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("TicketMedias") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Navigation("AccountLeftWorkList"); + + b.Navigation("CameraAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Navigation("AdminResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Navigation("TaskMessageList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Navigation("ClientResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Navigation("AdminResponseMedias"); + + b.Navigation("ClientResponseMedias"); + + b.Navigation("TaskMedias"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.PositionAgg.Position", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle1Agg.SubAccountPermissionSubtitle1", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle2Agg.SubAccountPermissionSubtitle2", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountPermissionSubtitle3Agg.SubAccountPermissionSubtitle3", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", b => + { + b.Navigation("SubAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Navigation("Assigns"); + + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.Navigation("TaskMessageItemsList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", b => + { + b.Navigation("TasksList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Navigation("AdminResponses"); + + b.Navigation("ClientResponses"); + + b.Navigation("TicketMedias"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20250530133036_add workshop to subAccountRole.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20250530133036_add workshop to subAccountRole.cs new file mode 100644 index 00000000..a7fd8eab --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20250530133036_add workshop to subAccountRole.cs @@ -0,0 +1,43 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + /// + public partial class addworkshoptosubAccountRole : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "SubAccountRoleWorkshop", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SubAccountId = table.Column(type: "bigint", nullable: false), + WorkshopId = table.Column(type: "bigint", nullable: false), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SubAccountRoleWorkshop", x => new { x.SubAccountId, x.id }); + table.ForeignKey( + name: "FK_SubAccountRoleWorkshop_SubAccountRoles_SubAccountId", + column: x => x.SubAccountId, + principalTable: "SubAccountRoles", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "SubAccountRoleWorkshop"); + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs b/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs index 153816a2..44a0ebd1 100644 --- a/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs +++ b/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs @@ -1078,6 +1078,33 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations modelBuilder.Entity("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRole", b => { + b.OwnsMany("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRoleWorkshop", "RoleWorkshops", b1 => + { + b1.Property("SubAccountId") + .HasColumnType("bigint"); + + b1.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("id")); + + b1.Property("CreationDate") + .HasColumnType("datetime2"); + + b1.Property("WorkshopId") + .HasColumnType("bigint"); + + b1.HasKey("SubAccountId", "id"); + + b1.ToTable("SubAccountRoleWorkshop"); + + b1.WithOwner("SubAccountRole") + .HasForeignKey("SubAccountId"); + + b1.Navigation("SubAccountRole"); + }); + b.OwnsMany("AccountManagement.Domain.SubAccountRoleAgg.SubAccountRolePermission", "RolePermissions", b1 => { b1.Property("id") @@ -1105,6 +1132,8 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations }); b.Navigation("RolePermissions"); + + b.Navigation("RoleWorkshops"); }); modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => diff --git a/AccountMangement.Infrastructure.EFCore/Repository/SubAccountRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/SubAccountRepository.cs index 8f54ad7a..1ea589e2 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/SubAccountRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/SubAccountRepository.cs @@ -77,5 +77,10 @@ namespace AccountMangement.Infrastructure.EFCore.Repository Username = entity.Username }; } + + public List GetBySubAccountRole(long subAccountRoleId) + { + return _context.SubAccounts.Where(x => x.SubAccountRoleId == subAccountRoleId).ToList(); + } } } diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs b/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs index e61afb0b..3f93090e 100644 --- a/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs +++ b/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs @@ -46,6 +46,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk } + public IActionResult OnPostShiftDate() { //var startRollCall = new DateTime(2025, 2, 19); @@ -79,6 +80,40 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk ViewData["message"] = "تومام یک"; return Page(); } + public async Task OnPostShiftDateNew2() + { + //var startRollCall = new DateTime(2025, 3, 21); + //var rollCalls = _context.RollCalls.Where(x => x.StartDate >= startRollCall && x.EndDate != null ).ToList(); + //var r1 = rollCalls.Skip(10000).Take(10000).ToList(); + + //Console.ForegroundColor = ConsoleColor.DarkRed; + //Console.WriteLine("endStep 1 ============"); + //SetRollCall(r1); + + await SetWorkshopRoleSubAccount(); + ViewData["message"] = "تومام دو"; + return Page(); + } + + private async System.Threading.Tasks.Task SetWorkshopRoleSubAccount() + { + var subAccountRoles = _accountContext.SubAccountRoles.Include(x=>x.SubAccounts).ToList(); + + subAccountRoles.ForEach(role => + { + var getSubAccount = role.SubAccounts.FirstOrDefault(); + if (getSubAccount != null) + { + var subAccount = getSubAccount.id; + + var workshopIds = _context.WorkshopSubAccounts.Where(x => x.SubAccountId == subAccount).Select(x => x.WorkshopId).ToList(); + role.Edit(role.Title, role.RolePermissions.Select(x => x.PermissionCode).ToList(), workshopIds); + } + + + }); + await _accountContext.SaveChangesAsync(); + } private void SetEntityIdForCheckoutValuesTemp() @@ -214,20 +249,6 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk } } - public async Task OnPostShiftDateNew2() - { - //var startRollCall = new DateTime(2025, 3, 21); - //var rollCalls = _context.RollCalls.Where(x => x.StartDate >= startRollCall && x.EndDate != null ).ToList(); - //var r1 = rollCalls.Skip(10000).Take(10000).ToList(); - - //Console.ForegroundColor = ConsoleColor.DarkRed; - //Console.WriteLine("endStep 1 ============"); - //SetRollCall(r1); - - await SetCalculationDateInSalaryAid(); - ViewData["message"] = "تومام دو"; - return Page(); - } private async System.Threading.Tasks.Task SetCalculationDateInSalaryAid() { diff --git a/ServiceHost/Areas/Client/Pages/Company/SubAccounts/Index.cshtml b/ServiceHost/Areas/Client/Pages/Company/SubAccounts/Index.cshtml index 1df655e1..a9e483a1 100644 --- a/ServiceHost/Areas/Client/Pages/Company/SubAccounts/Index.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/SubAccounts/Index.cshtml @@ -348,9 +348,9 @@ *@ - -