diff --git a/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs b/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs index 5db99227..108ea878 100644 --- a/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs +++ b/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs @@ -109,7 +109,7 @@ public static class PlatformConsts public static string BranchValues = $"SELECT \"{SelectCommandByTableName("Branch")}\".\"Id\" AS \"Key\", " + $"\"{SelectCommandByTableName("Branch")}\".\"Name\" as \"Name\" " + - $"FROM \"{SelectCommandByTableName("Branch")}\" " + + $"FROM \"KURS\".\"dbo\".\"{SelectCommandByTableName("Branch")}\" " + $"WHERE \"{SelectCommandByTableName("Branch")}\".\"TenantId\" = '@TENANTID' " + $"AND \"{SelectCommandByTableName("Branch")}\".\"Id\" IN ( " + $"SELECT [BranchId] " + diff --git a/api/src/Kurs.Platform.Domain/Entities/Branch/BranchUsers.cs b/api/src/Kurs.Platform.Domain/Entities/Branch/BranchUsers.cs index 5be44222..cf5ede25 100644 --- a/api/src/Kurs.Platform.Domain/Entities/Branch/BranchUsers.cs +++ b/api/src/Kurs.Platform.Domain/Entities/Branch/BranchUsers.cs @@ -12,6 +12,4 @@ public class BranchUsers : Entity, IMultiTenant public Guid UserId { get; set; } Guid? IMultiTenant.TenantId => TenantId; - - public virtual Branch Branch { get; set; } } diff --git a/api/src/Kurs.Platform.Domain/Entities/Tenant/Branch.cs b/api/src/Kurs.Platform.Domain/Entities/Tenant/Branch.cs index 9e1c12e2..3f3190fb 100644 --- a/api/src/Kurs.Platform.Domain/Entities/Tenant/Branch.cs +++ b/api/src/Kurs.Platform.Domain/Entities/Tenant/Branch.cs @@ -25,6 +25,4 @@ public class Branch : FullAuditedEntity public string Email { get; set; } public string Website { get; set; } public bool? IsActive { get; set; } - - public virtual ICollection Users { get; set; } } diff --git a/api/src/Kurs.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs b/api/src/Kurs.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs index c55dafb9..47af45ee 100644 --- a/api/src/Kurs.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs +++ b/api/src/Kurs.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs @@ -237,11 +237,6 @@ public class PlatformDbContext : b.Property(a => a.Email).HasMaxLength(128); b.Property(a => a.Website).HasMaxLength(128); b.Property(a => a.IsActive).HasDefaultValue(true); - - b.HasMany(x => x.Users) - .WithOne(x => x.Branch) - .HasForeignKey(x => x.BranchId) - .OnDelete(DeleteBehavior.Cascade); }); builder.Entity(b => diff --git a/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010064947_Initial.Designer.cs b/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010230305_Initial.Designer.cs similarity index 99% rename from api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010064947_Initial.Designer.cs rename to api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010230305_Initial.Designer.cs index e22be7fb..9eb9493d 100644 --- a/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010064947_Initial.Designer.cs +++ b/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010230305_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Kurs.Platform.Migrations { [DbContext(typeof(PlatformDbContext))] - [Migration("20251010064947_Initial")] + [Migration("20251010230305_Initial")] partial class Initial { /// @@ -1369,8 +1369,6 @@ namespace Kurs.Platform.Migrations b.HasKey("UserId", "BranchId"); - b.HasIndex("BranchId"); - b.ToTable("PBranchUsers", (string)null); }); @@ -8650,17 +8648,6 @@ namespace Kurs.Platform.Migrations b.Navigation("Category"); }); - modelBuilder.Entity("Kurs.Platform.Entities.BranchUsers", b => - { - b.HasOne("Kurs.Platform.Entities.Branch", "Branch") - .WithMany("Users") - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Branch"); - }); - modelBuilder.Entity("Kurs.Platform.Entities.City", b => { b.HasOne("Kurs.Platform.Entities.Country", null) @@ -9113,11 +9100,6 @@ namespace Kurs.Platform.Migrations b.Navigation("Posts"); }); - modelBuilder.Entity("Kurs.Platform.Entities.Branch", b => - { - b.Navigation("Users"); - }); - modelBuilder.Entity("Kurs.Platform.Entities.City", b => { b.Navigation("Districts"); diff --git a/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010064947_Initial.cs b/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010230305_Initial.cs similarity index 99% rename from api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010064947_Initial.cs rename to api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010230305_Initial.cs index 43efea5a..01184818 100644 --- a/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010064947_Initial.cs +++ b/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20251010230305_Initial.cs @@ -1306,6 +1306,20 @@ namespace Kurs.Platform.Migrations table.PrimaryKey("PK_PBranch", x => x.Id); }); + migrationBuilder.CreateTable( + name: "PBranchUsers", + columns: table => new + { + BranchId = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Id = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PBranchUsers", x => new { x.UserId, x.BranchId }); + }); + migrationBuilder.CreateTable( name: "PClassroom", columns: table => new @@ -2606,26 +2620,6 @@ namespace Kurs.Platform.Migrations onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "PBranchUsers", - columns: table => new - { - BranchId = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Id = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_PBranchUsers", x => new { x.UserId, x.BranchId }); - table.ForeignKey( - name: "FK_PBranchUsers_PBranch_BranchId", - column: x => x.BranchId, - principalTable: "PBranch", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "PClassroomAttandance", columns: table => new @@ -3857,11 +3851,6 @@ namespace Kurs.Platform.Migrations columns: new[] { "TableName", "Order" }, unique: true); - migrationBuilder.CreateIndex( - name: "IX_PBranchUsers_BranchId", - table: "PBranchUsers", - column: "BranchId"); - migrationBuilder.CreateIndex( name: "IX_PClassroom_ScheduledStartTime", table: "PClassroom", @@ -4239,6 +4228,9 @@ namespace Kurs.Platform.Migrations migrationBuilder.DropTable( name: "PBackgroundWorker_MailQueueEvents"); + migrationBuilder.DropTable( + name: "PBranch"); + migrationBuilder.DropTable( name: "PBranchUsers"); @@ -4377,9 +4369,6 @@ namespace Kurs.Platform.Migrations migrationBuilder.DropTable( name: "PBackgroundWorker_MailQueue"); - migrationBuilder.DropTable( - name: "PBranch"); - migrationBuilder.DropTable( name: "PClassroom"); diff --git a/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs b/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs index 64d42300..329299fe 100644 --- a/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs +++ b/api/src/Kurs.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs @@ -1366,8 +1366,6 @@ namespace Kurs.Platform.Migrations b.HasKey("UserId", "BranchId"); - b.HasIndex("BranchId"); - b.ToTable("PBranchUsers", (string)null); }); @@ -8647,17 +8645,6 @@ namespace Kurs.Platform.Migrations b.Navigation("Category"); }); - modelBuilder.Entity("Kurs.Platform.Entities.BranchUsers", b => - { - b.HasOne("Kurs.Platform.Entities.Branch", "Branch") - .WithMany("Users") - .HasForeignKey("BranchId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Branch"); - }); - modelBuilder.Entity("Kurs.Platform.Entities.City", b => { b.HasOne("Kurs.Platform.Entities.Country", null) @@ -9110,11 +9097,6 @@ namespace Kurs.Platform.Migrations b.Navigation("Posts"); }); - modelBuilder.Entity("Kurs.Platform.Entities.Branch", b => - { - b.Navigation("Users"); - }); - modelBuilder.Entity("Kurs.Platform.Entities.City", b => { b.Navigation("Districts");