From c04f802b393fcb1573f4f695c88608e2cdf025fe Mon Sep 17 00:00:00 2001 From: Akith-002 Date: Fri, 18 Jul 2025 08:27:14 +0530 Subject: [PATCH 1/4] feat: Add conditional database reset logic based on environment variable --- Data/DBInitializer.cs | 176 ++++++++++++++++++++++++++---------------- Program.cs | 10 +++ 2 files changed, 119 insertions(+), 67 deletions(-) diff --git a/Data/DBInitializer.cs b/Data/DBInitializer.cs index 7e66589..9f30907 100644 --- a/Data/DBInitializer.cs +++ b/Data/DBInitializer.cs @@ -31,8 +31,8 @@ public static void Initialize(AppDbContext context) // Update UserTasks with correct User IDs UpdateUserTaskUserIds(context); - // Remove UserTasks that are not LM (Land Miscellaneous) - RemoveNonLMUserTasks(context); + // Remove UserTasks that are not LM (Land Miscellaneous) - COMMENTED OUT to keep LA and MR tasks + // RemoveNonLMUserTasks(context); // Initialize Master Data InitializeMasterData(context); // Initialize Land Aquisition Master Files @@ -1048,7 +1048,7 @@ private static void InitializeReports(AppDbContext context) private static void InitializeUsers(AppDbContext context) { - //if (context.Users.Any()) return; + if (context.Users.Any()) return; Console.WriteLine("Seeding users..."); @@ -1136,18 +1136,31 @@ string division private static void InitializeUserTasks(AppDbContext context) { - // Calculate expected task count: 12 LA tasks + number of LM records - var expectedTaskCount = 12 + context.LandMiscellaneousMasterFiles.Count(); + // Calculate expected task count: 12 LA/MR tasks + number of LM records + var expectedLmTaskCount = context.LandMiscellaneousMasterFiles.Count(); + var expectedNonLmTaskCount = 12; + var currentLmTaskCount = context.UserTasks.Count(t => t.TaskType == "LM"); + var currentNonLmTaskCount = context.UserTasks.Count(t => t.TaskType != "LM"); - // Check if we already have enough tasks - if (context.UserTasks.Count() >= expectedTaskCount) + // Check if we have sufficient LM tasks - only reseed LM tasks if needed + bool needLmTasks = currentLmTaskCount < expectedLmTaskCount; + bool needNonLmTasks = currentNonLmTaskCount < expectedNonLmTaskCount; + + if (!needLmTasks && !needNonLmTasks) return; - // Remove all existing user tasks to ensure clean seeding - if (context.UserTasks.Any()) + // Only remove non-LM tasks if we need to reseed them + if (needNonLmTasks && currentNonLmTaskCount > 0) { - context.UserTasks.RemoveRange(context.UserTasks); + var nonLmTasks = context.UserTasks.Where(t => t.TaskType != "LM").ToList(); + Console.WriteLine($"Removing {nonLmTasks.Count} UserTask entries with TaskType other than 'LM'..."); + foreach (var task in nonLmTasks) + { + Console.WriteLine($"Removing UserTask: Username={task.Username}, TaskType={task.TaskType}, Description={task.WorkItemDescription}"); + } + context.UserTasks.RemoveRange(nonLmTasks); context.SaveChanges(); + Console.WriteLine("Non-LM UserTasks removed successfully."); } Console.WriteLine("Seeding user tasks..."); @@ -1188,57 +1201,92 @@ void AddTask(string username, string type, bool completed, string date, ); } - // Non-LM tasks (LA and MR tasks without referencing old LandMiscellaneous IDs) - // Jalina's tasks - AddTask("Jalina", "LA", true, "20250105", landAcquisitionId: 1, description: "Land acquisition survey for Highway Project", referenceNumber: "LA-2025-001"); - AddTask("Jalina", "MR", true, "20250115", requestId: 1, description: "Mass rating assessment - Colombo MC", referenceNumber: "MR-2025-001"); - AddTask("Jalina", "LA", true, "20250301", landAcquisitionId: 2, description: "Land acquisition for Bridge Project", referenceNumber: "LA-2025-002"); - - // Akith's tasks - AddTask("Akith", "MR", true, "20250120", requestId: 2, description: "Rating assessment - Galle MC", referenceNumber: "MR-2025-002"); - AddTask("Akith", "LA", false, "20250225", landAcquisitionId: 3, description: "Land acquisition survey", referenceNumber: "LA-2025-003"); - - // Dulmini's tasks - AddTask("Dulmini", "LA", true, "20250110", landAcquisitionId: 4, description: "Land acquisition documentation", referenceNumber: "LA-2025-004"); - AddTask("Dulmini", "MR", true, "20250112", requestId: 3, description: "Rating building assessment", referenceNumber: "MR-2025-003"); - AddTask("Dulmini", "MR", false, "20250302", requestId: 1, description: "Follow-up rating assessment", referenceNumber: "MR-2025-004"); - - // Vishwa's tasks - AddTask("Vishwa", "LA", true, "20250101", landAcquisitionId: 5, description: "Land acquisition initial survey", referenceNumber: "LA-2025-005"); - AddTask("Vishwa", "LA", true, "20250215", landAcquisitionId: 6, description: "Land acquisition follow-up", referenceNumber: "LA-2025-006"); - AddTask("Vishwa", "MR", true, "20250318", requestId: 2, description: "Additional rating assessment", referenceNumber: "MR-2025-005"); - - // Rithara's tasks - AddTask("Rithara", "MR", true, "20250118", requestId: 3, description: "Building rating review", referenceNumber: "MR-2025-006"); - AddTask("Rithara", "LA", false, "20250311", landAcquisitionId: 7, description: "Land acquisition assessment", referenceNumber: "LA-2025-007"); - - // LM tasks for all current land miscellaneous records - randomly distributed - var users = new[] { "Jalina", "Akith", "Dulmini", "Vishwa", "Rithara" }; - var planTypes = new[] { "PP", "Cadaster", "FVP" }; - var random = new Random(42); // Fixed seed for consistent results - - // Get all actual LandMiscellaneous records from database to use their real IDs - var landMiscRecords = context.LandMiscellaneousMasterFiles.OrderBy(lm => lm.MasterFileNo).ToList(); + // Add non-LM tasks only if needed + if (needNonLmTasks) + { + // Non-LM tasks (LA and MR tasks without referencing old LandMiscellaneous IDs) + // Jalina's tasks + AddTask("Jalina", "LA", true, "20250105", landAcquisitionId: 1, description: "Land acquisition survey for Highway Project", referenceNumber: "LA-2025-001"); + AddTask("Jalina", "MR", true, "20250115", requestId: 1, description: "Mass rating assessment - Colombo MC", referenceNumber: "MR-2025-001"); + AddTask("Jalina", "LA", true, "20250301", landAcquisitionId: 2, description: "Land acquisition for Bridge Project", referenceNumber: "LA-2025-002"); + + // Akith's tasks + AddTask("Akith", "MR", true, "20250120", requestId: 2, description: "Rating assessment - Galle MC", referenceNumber: "MR-2025-002"); + AddTask("Akith", "LA", false, "20250225", landAcquisitionId: 3, description: "Land acquisition survey", referenceNumber: "LA-2025-003"); + + // Dulmini's tasks + AddTask("Dulmini", "LA", true, "20250110", landAcquisitionId: 4, description: "Land acquisition documentation", referenceNumber: "LA-2025-004"); + AddTask("Dulmini", "MR", true, "20250112", requestId: 3, description: "Rating building assessment", referenceNumber: "MR-2025-003"); + AddTask("Dulmini", "MR", false, "20250302", requestId: 1, description: "Follow-up rating assessment", referenceNumber: "MR-2025-004"); + + // Vishwa's tasks + AddTask("Vishwa", "LA", true, "20250101", landAcquisitionId: 5, description: "Land acquisition initial survey", referenceNumber: "LA-2025-005"); + AddTask("Vishwa", "LA", true, "20250215", landAcquisitionId: 6, description: "Land acquisition follow-up", referenceNumber: "LA-2025-006"); + AddTask("Vishwa", "MR", true, "20250318", requestId: 2, description: "Additional rating assessment", referenceNumber: "MR-2025-005"); + + // Rithara's tasks + AddTask("Rithara", "MR", true, "20250118", requestId: 3, description: "Building rating review", referenceNumber: "MR-2025-006"); + AddTask("Rithara", "LA", false, "20250311", landAcquisitionId: 7, description: "Land acquisition assessment", referenceNumber: "LA-2025-007"); + + // Additional LA tasks for remaining Land Acquisition Master Files (IDs 8-22) + // Distribute among all 5 users + AddTask("Jalina", "LA", true, "20250315", landAcquisitionId: 8, description: "Land acquisition survey for Metro Line", referenceNumber: "LA-2025-008"); + AddTask("Akith", "LA", false, "20250320", landAcquisitionId: 9, description: "Land acquisition for School Development", referenceNumber: "LA-2025-009"); + AddTask("Dulmini", "LA", true, "20250325", landAcquisitionId: 10, description: "Land acquisition documentation review", referenceNumber: "LA-2025-010"); + AddTask("Vishwa", "LA", false, "20250330", landAcquisitionId: 11, description: "Land acquisition field verification", referenceNumber: "LA-2025-011"); + AddTask("Rithara", "LA", true, "20250405", landAcquisitionId: 12, description: "Land acquisition boundary survey", referenceNumber: "LA-2025-012"); + + AddTask("Jalina", "LA", false, "20250410", landAcquisitionId: 13, description: "Land acquisition for Hospital Extension", referenceNumber: "LA-2025-013"); + AddTask("Akith", "LA", true, "20250415", landAcquisitionId: 14, description: "Land acquisition compensation assessment", referenceNumber: "LA-2025-014"); + AddTask("Dulmini", "LA", false, "20250420", landAcquisitionId: 15, description: "Land acquisition legal documentation", referenceNumber: "LA-2025-015"); + AddTask("Vishwa", "LA", true, "20250425", landAcquisitionId: 16, description: "Land acquisition site inspection", referenceNumber: "LA-2025-016"); + AddTask("Rithara", "LA", false, "20250430", landAcquisitionId: 17, description: "Land acquisition valuation report", referenceNumber: "LA-2025-017"); + + AddTask("Jalina", "LA", true, "20250505", landAcquisitionId: 18, description: "Land acquisition for Road Widening", referenceNumber: "LA-2025-018"); + AddTask("Akith", "LA", false, "20250510", landAcquisitionId: 19, description: "Land acquisition preliminary survey", referenceNumber: "LA-2025-019"); + AddTask("Dulmini", "LA", true, "20250515", landAcquisitionId: 20, description: "Land acquisition title verification", referenceNumber: "LA-2025-020"); + AddTask("Vishwa", "LA", false, "20250520", landAcquisitionId: 21, description: "Land acquisition environmental assessment", referenceNumber: "LA-2025-021"); + AddTask("Rithara", "LA", true, "20250525", landAcquisitionId: 22, description: "Land acquisition final documentation", referenceNumber: "LA-2025-022"); + } - // Create tasks for each actual LandMiscellaneous record - for (int i = 0; i < landMiscRecords.Count; i++) + // Add LM tasks only if needed + if (needLmTasks) { - var record = landMiscRecords[i]; - var randomUser = users[random.Next(users.Length)]; - var randomPlanType = planTypes[random.Next(planTypes.Length)]; - var isCompleted = random.Next(100) < 30; // 30% chance of being completed - var randomDays = random.Next(1, 120); // Random date within last 120 days - var assignedDate = DateTime.Today.AddDays(-randomDays).ToString("yyyyMMdd"); - - AddTask(randomUser, "LM", isCompleted, assignedDate, - landMiscellaneousId: record.Id, // Use the actual database ID - description: $"{randomPlanType} plan verification for {record.MasterFileNo}", - referenceNumber: $"LM-2025-{(i + 1):D3}"); + // LM tasks for all current land miscellaneous records - randomly distributed + var users = new[] { "Jalina", "Akith", "Dulmini", "Vishwa", "Rithara" }; + var planTypes = new[] { "PP", "Cadaster", "FVP" }; + var random = new Random(42); // Fixed seed for consistent results + + // Get all actual LandMiscellaneous records from database to use their real IDs + var landMiscRecords = context.LandMiscellaneousMasterFiles.OrderBy(lm => lm.MasterFileNo).ToList(); + + // Create tasks for each actual LandMiscellaneous record + for (int i = 0; i < landMiscRecords.Count; i++) + { + var record = landMiscRecords[i]; + var randomUser = users[random.Next(users.Length)]; + var randomPlanType = planTypes[random.Next(planTypes.Length)]; + var isCompleted = random.Next(100) < 30; // 30% chance of being completed + var randomDays = random.Next(1, 120); // Random date within last 120 days + var assignedDate = DateTime.Today.AddDays(-randomDays).ToString("yyyyMMdd"); + + AddTask(randomUser, "LM", isCompleted, assignedDate, + landMiscellaneousId: record.Id, // Use the actual database ID + description: $"{randomPlanType} plan verification for {record.MasterFileNo}", + referenceNumber: $"LM-2025-{(i + 1):D3}"); + } } - context.UserTasks.AddRange(tasks); - context.SaveChanges(); - Console.WriteLine("User tasks seeded."); + if (tasks.Any()) + { + context.UserTasks.AddRange(tasks); + context.SaveChanges(); + Console.WriteLine($"User tasks seeded. Added {tasks.Count} tasks (LM: {tasks.Count(t => t.TaskType == "LM")}, Non-LM: {tasks.Count(t => t.TaskType != "LM")})."); + } + else + { + Console.WriteLine("No new tasks needed - all UserTasks are already properly seeded."); + } } private static void UpdateUserTaskAssignments(AppDbContext context) @@ -1483,12 +1531,9 @@ private static void InitializeRequestTypes(AppDbContext context) private static void InitializeRequests(AppDbContext context) { - // Clear existing data to allow reseeding + // Only seed if no requests exist if (context.Requests.Any()) - { - context.Requests.RemoveRange(context.Requests); - context.SaveChanges(); - } + return; Console.WriteLine("Seeding requests..."); @@ -1664,12 +1709,9 @@ private static void InitializeRequests(AppDbContext context) private static void InitializeAssets(AppDbContext context) { - // Clear existing data to allow reseeding + // Only seed if no assets exist if (context.Assets.Any()) - { - context.Assets.RemoveRange(context.Assets); - context.SaveChanges(); - } + return; Console.WriteLine("Seeding assets..."); diff --git a/Program.cs b/Program.cs index 48ba25a..e6ba50d 100644 --- a/Program.cs +++ b/Program.cs @@ -100,6 +100,16 @@ try { var dbContext = scope.ServiceProvider.GetRequiredService(); + + // Only reset database if explicitly requested (e.g., via environment variable) + var shouldResetDb = Environment.GetEnvironmentVariable("RESET_DATABASE")?.ToLower() == "true"; + + if (shouldResetDb) + { + Console.WriteLine("Resetting database..."); + // Add database reset logic here if needed + } + DbInitializer.Initialize(dbContext); Console.WriteLine("Database initialized successfully."); } From 4e33131ff380051cca096654bdefd5573b48f8dc Mon Sep 17 00:00:00 2001 From: Akith-002 Date: Mon, 21 Jul 2025 07:07:43 +0530 Subject: [PATCH 2/4] Add MasterFileRefNo to LandMiscellaneousMasterFiles - Created a new migration to add the MasterFileRefNo column to the LandMiscellaneousMasterFiles table. - Updated existing records to populate MasterFileRefNo based on MasterFileNo. - Updated the AppDbContextModelSnapshot to reflect the new column. - Modified the LandMiscellaneousMasterFile model to include the MasterFileRefNo property. --- ...oToLandMiscellaneousMasterFile.Designer.cs | 1714 +++++++++++++++++ ...rFileRefNoToLandMiscellaneousMasterFile.cs | 35 + Migrations/AppDbContextModelSnapshot.cs | 3 + Models/LandMiscellaneousMasterFile.cs | 1 + 4 files changed, 1753 insertions(+) create mode 100644 Migrations/20250720064824_AddMasterFileRefNoToLandMiscellaneousMasterFile.Designer.cs create mode 100644 Migrations/20250720064824_AddMasterFileRefNoToLandMiscellaneousMasterFile.cs diff --git a/Migrations/20250720064824_AddMasterFileRefNoToLandMiscellaneousMasterFile.Designer.cs b/Migrations/20250720064824_AddMasterFileRefNoToLandMiscellaneousMasterFile.Designer.cs new file mode 100644 index 0000000..608699d --- /dev/null +++ b/Migrations/20250720064824_AddMasterFileRefNoToLandMiscellaneousMasterFile.Designer.cs @@ -0,0 +1,1714 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using ValuationBackend.Data; + +#nullable disable + +namespace ValuationBackend.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20250720064824_AddMasterFileRefNoToLandMiscellaneousMasterFile")] + partial class AddMasterFileRefNoToLandMiscellaneousMasterFile + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LandAquisitionMasterFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("MasterFileNo") + .HasColumnType("integer"); + + b.Property("MasterFilesRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanType") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequestingAuthorityReferenceNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LandAquisitionMasterFiles"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Asset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNo") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("integer"); + + b.Property("IsRatingCard") + .HasColumnType("boolean"); + + b.Property("Owner") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("RdSt") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("RequestId") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Ward") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("RequestId"); + + b.ToTable("Assets"); + }); + + modelBuilder.Entity("ValuationBackend.Models.AssetDivision", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Area") + .HasColumnType("numeric"); + + b.Property("AssetId") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("LandType") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("NewAssetNo") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AssetId"); + + b.ToTable("AssetDivisions"); + }); + + modelBuilder.Entity("ValuationBackend.Models.AssetNumberChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChangedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfChange") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("FieldSize") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("FieldType") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("NewAssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OldAssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Reason") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("AssetNumberChanges"); + }); + + modelBuilder.Entity("ValuationBackend.Models.BuildingRatesLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNumber") + .HasColumnType("text"); + + b.Property("ConstructedBy") + .HasColumnType("text"); + + b.Property("Cost") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("FloorAreaSQFT") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePerSQFT") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("YearOfConstruction") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("BuildingRatesLA"); + }); + + modelBuilder.Entity("ValuationBackend.Models.ConditionReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccessCategory") + .IsRequired() + .HasColumnType("text"); + + b.Property("AccessCategoryDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("AcquiredExtent") + .IsRequired() + .HasColumnType("text"); + + b.Property("AcquiringOfficerSignature") + .IsRequired() + .HasColumnType("text"); + + b.Property("AcquisitionName") + .IsRequired() + .HasColumnType("text"); + + b.Property("AssessmentNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("AtLotNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("AtPlanNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryBottom") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryEast") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryNorth") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundarySouth") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryWest") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingInfo") + .IsRequired() + .HasColumnType("text"); + + b.Property("ChiefValuerRepresentativeSignature") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfSection3BA") + .IsRequired() + .HasColumnType("text"); + + b.Property("DatePrepared") + .IsRequired() + .HasColumnType("text"); + + b.Property("DepthOfLand") + .IsRequired() + .HasColumnType("text"); + + b.Property("DescriptionOfLand") + .IsRequired() + .HasColumnType("text"); + + b.Property("DetailsOfBusiness") + .IsRequired() + .HasColumnType("text"); + + b.Property("Frontage") + .IsRequired() + .HasColumnType("text"); + + b.Property("GramasewakaSignature") + .IsRequired() + .HasColumnType("text"); + + b.Property("LandUseDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("LandUseType") + .IsRequired() + .HasColumnType("text"); + + b.Property("LevelWithAccess") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameOfTheLand") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameOfTheVillage") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherConstructionsDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherConstructionsInfo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlantationDetails") + .IsRequired() + .HasColumnType("text"); + + b.Property("PpCadLotNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("PpCadNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("RoadName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("ConditionReports"); + }); + + modelBuilder.Entity("ValuationBackend.Models.DomesticRatingCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Access") + .HasColumnType("text"); + + b.Property("Age") + .HasColumnType("integer"); + + b.Property("AssetId") + .HasColumnType("integer"); + + b.Property("Condition") + .HasColumnType("text"); + + b.Property("Conveniences") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Floor") + .HasColumnType("text"); + + b.Property("NewNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("Notes") + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParkingSpace") + .HasColumnType("text"); + + b.Property("Plantations") + .HasColumnType("text"); + + b.Property("PropertySubCategory") + .HasColumnType("text"); + + b.Property("PropertyType") + .HasColumnType("text"); + + b.Property("RentPM") + .HasColumnType("numeric"); + + b.Property("RoadName") + .HasColumnType("text"); + + b.Property("SelectWalls") + .HasColumnType("text"); + + b.Property("SuggestedRate") + .HasColumnType("numeric"); + + b.Property("Terms") + .HasColumnType("text"); + + b.Property("TsBop") + .HasColumnType("text"); + + b.Property("WardNumber") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AssetId"); + + b.ToTable("DomesticRatingCards"); + }); + + modelBuilder.Entity("ValuationBackend.Models.ImageData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ImageBase64") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReportId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ImageData"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionBuilding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AgeYears") + .HasColumnType("text"); + + b.Property("BathroomToilet") + .HasColumnType("text"); + + b.Property("BathroomToiletDoorsFittings") + .HasColumnType("text"); + + b.Property("BuildingCategory") + .HasColumnType("text"); + + b.Property("BuildingClass") + .HasColumnType("text"); + + b.Property("BuildingConditions") + .HasColumnType("text"); + + b.Property("BuildingId") + .HasColumnType("text"); + + b.Property("BuildingName") + .HasColumnType("text"); + + b.Property("Ceiling") + .HasColumnType("text"); + + b.Property("Condition") + .HasColumnType("text"); + + b.Property("Conveniences") + .HasColumnType("text"); + + b.Property("Design") + .HasColumnType("text"); + + b.Property("DetailOfBuilding") + .HasColumnType("text"); + + b.Property("Door") + .HasColumnType("text"); + + b.Property("ExpectedLifePeriodYears") + .HasColumnType("text"); + + b.Property("FloorFinisher") + .HasColumnType("text"); + + b.Property("FloorStructure") + .HasColumnType("text"); + + b.Property("FoundationStructure") + .HasColumnType("text"); + + b.Property("HandRail") + .HasColumnType("text"); + + b.Property("InspectionReportId") + .HasColumnType("integer"); + + b.Property("NatureOfConstruction") + .HasColumnType("text"); + + b.Property("NoOfFloorsAboveGround") + .HasColumnType("text") + .HasColumnName("NoOfFloorsAboveGround"); + + b.Property("NoOfFloorsBelowGround") + .HasColumnType("text") + .HasColumnName("NoOfFloorsBelowGround"); + + b.Property("OtherDoors") + .HasColumnType("text"); + + b.Property("PantryCupboard") + .HasColumnType("text"); + + b.Property("ParkingSpace") + .HasColumnType("text"); + + b.Property("RoofFinisher") + .HasColumnType("text"); + + b.Property("RoofFrame") + .HasColumnType("text"); + + b.Property("RoofMaterial") + .HasColumnType("text"); + + b.Property("Services") + .HasColumnType("text"); + + b.Property("Structure") + .HasColumnType("text"); + + b.Property("WallFinisher") + .HasColumnType("text"); + + b.Property("WallStructure") + .HasColumnType("text"); + + b.Property("Window") + .HasColumnType("text"); + + b.Property("WindowProtection") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InspectionReportId"); + + b.ToTable("InspectionBuildings"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionReport", b => + { + b.Property("InspectionReportId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("InspectionReportId")); + + b.Property("DetailsOfAssestsInventoryItems") + .HasColumnType("text") + .HasColumnName("DetailsOfAssestsInventoryItems"); + + b.Property("DetailsOfBusiness") + .HasColumnType("text"); + + b.Property("District") + .HasColumnType("text"); + + b.Property("DsDivision") + .HasColumnType("text"); + + b.Property("GnDivision") + .HasColumnType("text"); + + b.Property("InspectionDate") + .HasColumnType("timestamp with time zone"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherConstructionDetails") + .HasColumnType("text"); + + b.Property("OtherInformation") + .HasColumnType("text"); + + b.Property("Province") + .HasColumnType("text"); + + b.Property("Remark") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Village") + .HasColumnType("text"); + + b.HasKey("InspectionReportId"); + + b.HasIndex("ReportId"); + + b.ToTable("InspectionReports"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMBuildingRates", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNumber") + .HasColumnType("text"); + + b.Property("ConstructedBy") + .HasColumnType("text"); + + b.Property("Cost") + .HasColumnType("text"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("FloorArea") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePerSQFT") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("YearOfConstruction") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("LMBuildingRates"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMPastValuation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateOfValuation") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("FileNo_GnDivision") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanOfParticulars") + .HasColumnType("text"); + + b.Property("PurposeOfValuation") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("LMPastValuations"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMRentalEvidence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNo") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("FloorRate") + .HasColumnType("text"); + + b.Property("HeadOfTerms") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePer") + .HasColumnType("text"); + + b.Property("RatePerMonth") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("LMRentalEvidences"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMSalesEvidence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNumber") + .HasColumnType("text"); + + b.Property("Consideration") + .HasColumnType("text"); + + b.Property("DeedAttestedNumber") + .HasColumnType("text"); + + b.Property("DeedNumber") + .HasColumnType("text"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("LandRegistryReferences") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("LotNumber") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("NotaryName") + .HasColumnType("text"); + + b.Property("PlanDate") + .HasColumnType("text"); + + b.Property("PlanNumber") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Road") + .HasColumnType("text"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("Vendor") + .HasColumnType("text"); + + b.Property("Village") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("LMSalesEvidences"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LandMiscellaneousMasterFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Lots") + .HasColumnType("integer"); + + b.Property("MasterFileNo") + .HasColumnType("integer"); + + b.Property("MasterFileRefNo") + .HasColumnType("text"); + + b.Property("PlanNo") + .HasColumnType("text"); + + b.Property("PlanType") + .HasColumnType("text"); + + b.Property("RequestingAuthorityReferenceNo") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LandMiscellaneousMasterFiles"); + }); + + modelBuilder.Entity("ValuationBackend.Models.MasterDataItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("MasterDataItems"); + }); + + modelBuilder.Entity("ValuationBackend.Models.PastValuationsLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfValuation") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("FileNoGNDivision") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanOfParticulars") + .HasColumnType("text"); + + b.Property("PurposeOfValuation") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("PastValuationsLA"); + }); + + modelBuilder.Entity("ValuationBackend.Models.PropertyCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("PropertyCategories"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RatingRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LocalAuthority") + .IsRequired() + .HasColumnType("text"); + + b.Property("RatingReferenceNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequestType") + .IsRequired() + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("YearOfRevision") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("RatingRequests"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Reconciliation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetId") + .HasColumnType("integer"); + + b.Property("NewNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ObsoleteNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("StreetName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AssetId"); + + b.ToTable("Reconciliations"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RentalEvidenceLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNo") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("FloorRateSQFT") + .HasColumnType("text"); + + b.Property("HeadOfTerms") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePerMonth") + .HasColumnType("text"); + + b.Property("RatePerSqft") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("RentalEvidencesLA", (string)null); + }); + + modelBuilder.Entity("ValuationBackend.Models.Report", b => + { + b.Property("ReportId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReportId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReportType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ReportId"); + + b.ToTable("Reports"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LocalAuthority") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("RatingReferenceNo") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("RequestTypeId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("boolean"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("YearOfRevision") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RequestTypeId"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RequestType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("character varying(2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("RequestTypes"); + }); + + modelBuilder.Entity("ValuationBackend.Models.SalesEvidenceLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNumber") + .HasColumnType("text"); + + b.Property("Consideration") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeedAttestedNumber") + .HasColumnType("text"); + + b.Property("DeedNumber") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("FloorRate") + .HasColumnType("text"); + + b.Property("LandRegistryReferences") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("LotNumber") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("NotaryName") + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("PlanDate") + .HasColumnType("text"); + + b.Property("PlanNumber") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Road") + .HasColumnType("text"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Vendor") + .HasColumnType("text"); + + b.Property("Village") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("SalesEvidencesLA", (string)null); + }); + + modelBuilder.Entity("ValuationBackend.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedDivision") + .IsRequired() + .HasColumnType("text"); + + b.Property("EmpEmail") + .IsRequired() + .HasColumnType("text"); + + b.Property("EmpId") + .IsRequired() + .HasColumnType("text"); + + b.Property("EmpName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("PasswordSalt") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("Position") + .IsRequired() + .HasColumnType("text"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("ValuationBackend.Models.UserTask", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsCompleted") + .HasColumnType("boolean"); + + b.Property("LandAcquisitionId") + .HasColumnType("integer"); + + b.Property("LandMiscellaneousId") + .HasColumnType("integer"); + + b.Property("ReferenceNumber") + .HasColumnType("text"); + + b.Property("RequestId") + .HasColumnType("integer"); + + b.Property("TaskType") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkItemDescription") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserTasks"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Asset", b => + { + b.HasOne("ValuationBackend.Models.Request", "Request") + .WithMany() + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("ValuationBackend.Models.AssetDivision", b => + { + b.HasOne("ValuationBackend.Models.Asset", "Asset") + .WithMany() + .HasForeignKey("AssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Asset"); + }); + + modelBuilder.Entity("ValuationBackend.Models.BuildingRatesLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.ConditionReport", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.DomesticRatingCard", b => + { + b.HasOne("ValuationBackend.Models.Asset", "Asset") + .WithMany() + .HasForeignKey("AssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Asset"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionBuilding", b => + { + b.HasOne("ValuationBackend.Models.InspectionReport", "InspectionReport") + .WithMany("Buildings") + .HasForeignKey("InspectionReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionReport"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionReport", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMBuildingRates", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMPastValuation", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMRentalEvidence", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMSalesEvidence", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.PastValuationsLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Reconciliation", b => + { + b.HasOne("ValuationBackend.Models.Asset", "Asset") + .WithMany() + .HasForeignKey("AssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Asset"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RentalEvidenceLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Request", b => + { + b.HasOne("ValuationBackend.Models.RequestType", "RequestType") + .WithMany() + .HasForeignKey("RequestTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RequestType"); + }); + + modelBuilder.Entity("ValuationBackend.Models.SalesEvidenceLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.UserTask", b => + { + b.HasOne("ValuationBackend.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionReport", b => + { + b.Navigation("Buildings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20250720064824_AddMasterFileRefNoToLandMiscellaneousMasterFile.cs b/Migrations/20250720064824_AddMasterFileRefNoToLandMiscellaneousMasterFile.cs new file mode 100644 index 0000000..10e34eb --- /dev/null +++ b/Migrations/20250720064824_AddMasterFileRefNoToLandMiscellaneousMasterFile.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ValuationBackend.Migrations +{ + /// + public partial class AddMasterFileRefNoToLandMiscellaneousMasterFile : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "MasterFileRefNo", + table: "LandMiscellaneousMasterFiles", + type: "text", + nullable: true); + + // Update existing records with MasterFileRefNo based on MasterFileNo + migrationBuilder.Sql(@" + UPDATE ""LandMiscellaneousMasterFiles"" + SET ""MasterFileRefNo"" = 'Metro 2/LA/' || ""MasterFileNo"" + WHERE ""MasterFileRefNo"" IS NULL; + "); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "MasterFileRefNo", + table: "LandMiscellaneousMasterFiles"); + } + } +} diff --git a/Migrations/AppDbContextModelSnapshot.cs b/Migrations/AppDbContextModelSnapshot.cs index fadf802..c3077b4 100644 --- a/Migrations/AppDbContextModelSnapshot.cs +++ b/Migrations/AppDbContextModelSnapshot.cs @@ -970,6 +970,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("MasterFileNo") .HasColumnType("integer"); + b.Property("MasterFileRefNo") + .HasColumnType("text"); + b.Property("PlanNo") .HasColumnType("text"); diff --git a/Models/LandMiscellaneousMasterFile.cs b/Models/LandMiscellaneousMasterFile.cs index ad6732e..75d97c8 100644 --- a/Models/LandMiscellaneousMasterFile.cs +++ b/Models/LandMiscellaneousMasterFile.cs @@ -6,6 +6,7 @@ public class LandMiscellaneousMasterFile { public int Id { get; set; } public int MasterFileNo { get; set; } + public string? MasterFileRefNo { get; set; } public string? PlanType { get; set; } public string? PlanNo { get; set; } public string? RequestingAuthorityReferenceNo { get; set; } From 97a7674ceab217eec78f63227bb34c4677b2c273 Mon Sep 17 00:00:00 2001 From: Akith-002 Date: Tue, 22 Jul 2025 11:30:23 +0530 Subject: [PATCH 3/4] feat: Add LandMiscellaneousMasterFileId to LMRentalEvidence - Introduced a new nullable foreign key column `LandMiscellaneousMasterFileId` in the `LMRentalEvidences` table. - Updated the `LMRentalEvidence` model to include the new foreign key and navigation property for `LandMiscellaneousMasterFile`. - Modified the DTOs to accommodate the new foreign key and added a DTO for `LandMiscellaneousMasterFile`. - Enhanced the repository interfaces and implementations to support fetching rental evidences by master file ID and reference number. - Updated the service layer to handle the new foreign key relationships and ensure proper data mapping. - Removed outdated sorting API documentation as it is no longer relevant. --- Controllers/DataMigrationController.cs | 69 + Controllers/LMRentalEvidenceController.cs | 24 + Data/AppDbContext.cs | 14 +- Data/DBInitializer.cs | 2 +- Data/PopulateForeignKeysMigration.cs | 99 + ...MasterFileIdToLMRentalEvidence.Designer.cs | 1734 +++++++++++++++++ ...ellaneousMasterFileIdToLMRentalEvidence.cs | 49 + Migrations/AppDbContextModelSnapshot.cs | 18 + Models/DTOs/LMRentalEvidenceDtos.cs | 28 + Models/LMRentalEvidence.cs | 10 +- SORTING_API_DOCUMENTATION.md | 85 - repositories/ILMRentalEvidenceRepository.cs | 7 + repositories/ILandMiscellaneousRepository.cs | 3 + repositories/LMRentalEvidenceRepository.cs | 30 + repositories/LandMiscellaneousRepository.cs | 7 + services/ILMRentalEvidenceService.cs | 10 +- services/LMRentalEvidenceService.cs | 75 +- 17 files changed, 2166 insertions(+), 98 deletions(-) create mode 100644 Controllers/DataMigrationController.cs create mode 100644 Data/PopulateForeignKeysMigration.cs create mode 100644 Migrations/20250722032612_AddLandMiscellaneousMasterFileIdToLMRentalEvidence.Designer.cs create mode 100644 Migrations/20250722032612_AddLandMiscellaneousMasterFileIdToLMRentalEvidence.cs delete mode 100644 SORTING_API_DOCUMENTATION.md diff --git a/Controllers/DataMigrationController.cs b/Controllers/DataMigrationController.cs new file mode 100644 index 0000000..62f155d --- /dev/null +++ b/Controllers/DataMigrationController.cs @@ -0,0 +1,69 @@ +using Microsoft.AspNetCore.Mvc; +using ValuationBackend.Data; + +namespace ValuationBackend.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class DataMigrationController : ControllerBase + { + private readonly AppDbContext _context; + + public DataMigrationController(AppDbContext context) + { + _context = context; + } + + /// + /// Populates foreign keys for LM Rental Evidence records based on existing string references + /// + [HttpPost("populate-lm-rental-evidence-foreign-keys")] + public async Task PopulateLMRentalEvidenceForeignKeys() + { + try + { + await PopulateForeignKeysMigration.PopulateLMRentalEvidenceForeignKeys(_context); + return Ok(new { message = "Foreign keys populated successfully for LM Rental Evidence." }); + } + catch (Exception ex) + { + return StatusCode(500, new { error = "Failed to populate foreign keys", details = ex.Message }); + } + } + + /// + /// Validates foreign key relationships for LM Rental Evidence + /// + [HttpGet("validate-lm-rental-evidence-foreign-keys")] + public async Task ValidateLMRentalEvidenceForeignKeys() + { + try + { + await PopulateForeignKeysMigration.ValidateForeignKeyRelationships(_context); + return Ok(new { message = "Foreign key validation completed. Check console output for details." }); + } + catch (Exception ex) + { + return StatusCode(500, new { error = "Failed to validate foreign keys", details = ex.Message }); + } + } + + /// + /// Runs both population and validation in sequence + /// + [HttpPost("migrate-lm-rental-evidence")] + public async Task MigrateLMRentalEvidence() + { + try + { + await PopulateForeignKeysMigration.PopulateLMRentalEvidenceForeignKeys(_context); + await PopulateForeignKeysMigration.ValidateForeignKeyRelationships(_context); + return Ok(new { message = "LM Rental Evidence migration completed successfully." }); + } + catch (Exception ex) + { + return StatusCode(500, new { error = "Failed to migrate LM Rental Evidence", details = ex.Message }); + } + } + } +} diff --git a/Controllers/LMRentalEvidenceController.cs b/Controllers/LMRentalEvidenceController.cs index ab60c3d..e0aa5b6 100644 --- a/Controllers/LMRentalEvidenceController.cs +++ b/Controllers/LMRentalEvidenceController.cs @@ -93,5 +93,29 @@ public async Task> GetLMRentalEvidence return lmRentalEvidence; } + + // NEW: GET: api/LMRentalEvidence/ByMasterFile/123 + [HttpGet("ByMasterFile/{masterFileId}")] + public async Task>> GetByMasterFileId(int masterFileId) + { + var evidences = await _lmRentalEvidenceService.GetByMasterFileIdAsync(masterFileId); + return Ok(evidences); + } + + // NEW: GET: api/LMRentalEvidence/ByMasterFileRefNo/MF-2024-001 + [HttpGet("ByMasterFileRefNo/{masterFileRefNo}")] + public async Task>> GetByMasterFileRefNo(string masterFileRefNo) + { + var evidences = await _lmRentalEvidenceService.GetByMasterFileRefNoAsync(masterFileRefNo); + return Ok(evidences); + } + + // NEW: GET: api/LMRentalEvidence/WithMasterFileData + [HttpGet("WithMasterFileData")] + public async Task>> GetAllWithMasterFileData() + { + var evidences = await _lmRentalEvidenceService.GetAllWithMasterFileDataAsync(); + return Ok(evidences); + } } } diff --git a/Data/AppDbContext.cs b/Data/AppDbContext.cs index b330b8c..864dbad 100644 --- a/Data/AppDbContext.cs +++ b/Data/AppDbContext.cs @@ -9,7 +9,7 @@ public AppDbContext(DbContextOptions options) : base(options) { } public DbSet RatingRequests { get; set; } - + public DbSet LandMiscellaneousMasterFiles { get; set; } public DbSet Reconciliations { get; set; } @@ -70,6 +70,18 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasOne(r => r.Asset) .WithMany() .HasForeignKey(r => r.AssetId); + + // NEW: Configure LMRentalEvidence relationships + modelBuilder.Entity() + .HasOne(lm => lm.LandMiscellaneousMasterFile) + .WithMany() + .HasForeignKey(lm => lm.LandMiscellaneousMasterFileId) + .OnDelete(DeleteBehavior.SetNull); + + // NEW: Add index for performance + modelBuilder.Entity() + .HasIndex(lm => lm.LandMiscellaneousMasterFileId) + .HasDatabaseName("IX_LMRentalEvidence_LandMiscellaneousMasterFileId"); } } } diff --git a/Data/DBInitializer.cs b/Data/DBInitializer.cs index 3145e64..9f30907 100644 --- a/Data/DBInitializer.cs +++ b/Data/DBInitializer.cs @@ -32,7 +32,7 @@ public static void Initialize(AppDbContext context) UpdateUserTaskUserIds(context); // Remove UserTasks that are not LM (Land Miscellaneous) - COMMENTED OUT to keep LA and MR tasks - // // RemoveNonLMUserTasks(context); + // RemoveNonLMUserTasks(context); // Initialize Master Data InitializeMasterData(context); // Initialize Land Aquisition Master Files diff --git a/Data/PopulateForeignKeysMigration.cs b/Data/PopulateForeignKeysMigration.cs new file mode 100644 index 0000000..a722272 --- /dev/null +++ b/Data/PopulateForeignKeysMigration.cs @@ -0,0 +1,99 @@ +using Microsoft.EntityFrameworkCore; +using ValuationBackend.Models; + +namespace ValuationBackend.Data +{ + public static class PopulateForeignKeysMigration + { + /// + /// Populates the LandMiscellaneousMasterFileId foreign key in LMRentalEvidence + /// based on existing MasterFileRefNo values + /// + public static async Task PopulateLMRentalEvidenceForeignKeys(AppDbContext context) + { + // Get all rental evidences where foreign key is null but string reference exists + var rentalEvidences = await context.LMRentalEvidences + .Where(re => re.LandMiscellaneousMasterFileId == null && + !string.IsNullOrEmpty(re.MasterFileRefNo)) + .ToListAsync(); + + if (!rentalEvidences.Any()) + { + Console.WriteLine("No rental evidences found that need foreign key population."); + return; + } + + Console.WriteLine($"Found {rentalEvidences.Count} rental evidences to update."); + + int updatedCount = 0; + int skippedCount = 0; + + foreach (var evidence in rentalEvidences) + { + // Find the corresponding master file + var masterFile = await context.LandMiscellaneousMasterFiles + .FirstOrDefaultAsync(mf => mf.MasterFileRefNo == evidence.MasterFileRefNo); + + if (masterFile != null) + { + evidence.LandMiscellaneousMasterFileId = masterFile.Id; + updatedCount++; + Console.WriteLine($"Updated rental evidence ID {evidence.Id} with master file ID {masterFile.Id}"); + } + else + { + skippedCount++; + Console.WriteLine($"Warning: No master file found for reference number '{evidence.MasterFileRefNo}' (Rental Evidence ID: {evidence.Id})"); + } + } + + if (updatedCount > 0) + { + await context.SaveChangesAsync(); + Console.WriteLine($"Successfully updated {updatedCount} rental evidence records."); + } + + if (skippedCount > 0) + { + Console.WriteLine($"Skipped {skippedCount} records due to missing master file references."); + } + } + + /// + /// Validates the foreign key relationships after population + /// + public static async Task ValidateForeignKeyRelationships(AppDbContext context) + { + // Check for rental evidences with valid foreign keys + var withForeignKeys = await context.LMRentalEvidences + .CountAsync(re => re.LandMiscellaneousMasterFileId.HasValue); + + // Check for rental evidences without foreign keys but with string references + var withoutForeignKeys = await context.LMRentalEvidences + .CountAsync(re => !re.LandMiscellaneousMasterFileId.HasValue && + !string.IsNullOrEmpty(re.MasterFileRefNo)); + + // Check for orphaned references (string references that don't match any master file) + var orphanedReferences = await context.LMRentalEvidences + .Where(re => !string.IsNullOrEmpty(re.MasterFileRefNo)) + .Where(re => !context.LandMiscellaneousMasterFiles + .Any(mf => mf.MasterFileRefNo == re.MasterFileRefNo)) + .CountAsync(); + + Console.WriteLine("=== Foreign Key Relationship Validation ==="); + Console.WriteLine($"Rental evidences with foreign keys: {withForeignKeys}"); + Console.WriteLine($"Rental evidences without foreign keys (but with string refs): {withoutForeignKeys}"); + Console.WriteLine($"Orphaned string references: {orphanedReferences}"); + + if (withoutForeignKeys > 0) + { + Console.WriteLine("Warning: Some rental evidences still lack foreign key relationships."); + } + + if (orphanedReferences > 0) + { + Console.WriteLine("Warning: Some rental evidences reference master files that don't exist."); + } + } + } +} diff --git a/Migrations/20250722032612_AddLandMiscellaneousMasterFileIdToLMRentalEvidence.Designer.cs b/Migrations/20250722032612_AddLandMiscellaneousMasterFileIdToLMRentalEvidence.Designer.cs new file mode 100644 index 0000000..9593b8d --- /dev/null +++ b/Migrations/20250722032612_AddLandMiscellaneousMasterFileIdToLMRentalEvidence.Designer.cs @@ -0,0 +1,1734 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using ValuationBackend.Data; + +#nullable disable + +namespace ValuationBackend.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20250722032612_AddLandMiscellaneousMasterFileIdToLMRentalEvidence")] + partial class AddLandMiscellaneousMasterFileIdToLMRentalEvidence + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LandAquisitionMasterFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("MasterFileNo") + .HasColumnType("integer"); + + b.Property("MasterFilesRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanType") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequestingAuthorityReferenceNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LandAquisitionMasterFiles"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Asset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNo") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("integer"); + + b.Property("IsRatingCard") + .HasColumnType("boolean"); + + b.Property("Owner") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("RdSt") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("RequestId") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Ward") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("RequestId"); + + b.ToTable("Assets"); + }); + + modelBuilder.Entity("ValuationBackend.Models.AssetDivision", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Area") + .HasColumnType("numeric"); + + b.Property("AssetId") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("LandType") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("NewAssetNo") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AssetId"); + + b.ToTable("AssetDivisions"); + }); + + modelBuilder.Entity("ValuationBackend.Models.AssetNumberChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChangedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfChange") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("FieldSize") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("FieldType") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("NewAssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OldAssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Reason") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("AssetNumberChanges"); + }); + + modelBuilder.Entity("ValuationBackend.Models.BuildingRatesLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNumber") + .HasColumnType("text"); + + b.Property("ConstructedBy") + .HasColumnType("text"); + + b.Property("Cost") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("FloorAreaSQFT") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePerSQFT") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("YearOfConstruction") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("BuildingRatesLA"); + }); + + modelBuilder.Entity("ValuationBackend.Models.ConditionReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccessCategory") + .IsRequired() + .HasColumnType("text"); + + b.Property("AccessCategoryDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("AcquiredExtent") + .IsRequired() + .HasColumnType("text"); + + b.Property("AcquiringOfficerSignature") + .IsRequired() + .HasColumnType("text"); + + b.Property("AcquisitionName") + .IsRequired() + .HasColumnType("text"); + + b.Property("AssessmentNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("AtLotNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("AtPlanNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryBottom") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryEast") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryNorth") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundarySouth") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryWest") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingInfo") + .IsRequired() + .HasColumnType("text"); + + b.Property("ChiefValuerRepresentativeSignature") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfSection3BA") + .IsRequired() + .HasColumnType("text"); + + b.Property("DatePrepared") + .IsRequired() + .HasColumnType("text"); + + b.Property("DepthOfLand") + .IsRequired() + .HasColumnType("text"); + + b.Property("DescriptionOfLand") + .IsRequired() + .HasColumnType("text"); + + b.Property("DetailsOfBusiness") + .IsRequired() + .HasColumnType("text"); + + b.Property("Frontage") + .IsRequired() + .HasColumnType("text"); + + b.Property("GramasewakaSignature") + .IsRequired() + .HasColumnType("text"); + + b.Property("LandUseDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("LandUseType") + .IsRequired() + .HasColumnType("text"); + + b.Property("LevelWithAccess") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameOfTheLand") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameOfTheVillage") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherConstructionsDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherConstructionsInfo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlantationDetails") + .IsRequired() + .HasColumnType("text"); + + b.Property("PpCadLotNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("PpCadNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("RoadName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("ConditionReports"); + }); + + modelBuilder.Entity("ValuationBackend.Models.DomesticRatingCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Access") + .HasColumnType("text"); + + b.Property("Age") + .HasColumnType("integer"); + + b.Property("AssetId") + .HasColumnType("integer"); + + b.Property("Condition") + .HasColumnType("text"); + + b.Property("Conveniences") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Floor") + .HasColumnType("text"); + + b.Property("NewNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("Notes") + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParkingSpace") + .HasColumnType("text"); + + b.Property("Plantations") + .HasColumnType("text"); + + b.Property("PropertySubCategory") + .HasColumnType("text"); + + b.Property("PropertyType") + .HasColumnType("text"); + + b.Property("RentPM") + .HasColumnType("numeric"); + + b.Property("RoadName") + .HasColumnType("text"); + + b.Property("SelectWalls") + .HasColumnType("text"); + + b.Property("SuggestedRate") + .HasColumnType("numeric"); + + b.Property("Terms") + .HasColumnType("text"); + + b.Property("TsBop") + .HasColumnType("text"); + + b.Property("WardNumber") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AssetId"); + + b.ToTable("DomesticRatingCards"); + }); + + modelBuilder.Entity("ValuationBackend.Models.ImageData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ImageBase64") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("ImageData"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionBuilding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AgeYears") + .HasColumnType("text"); + + b.Property("BathroomToilet") + .HasColumnType("text"); + + b.Property("BathroomToiletDoorsFittings") + .HasColumnType("text"); + + b.Property("BuildingCategory") + .HasColumnType("text"); + + b.Property("BuildingClass") + .HasColumnType("text"); + + b.Property("BuildingConditions") + .HasColumnType("text"); + + b.Property("BuildingId") + .HasColumnType("text"); + + b.Property("BuildingName") + .HasColumnType("text"); + + b.Property("Ceiling") + .HasColumnType("text"); + + b.Property("Condition") + .HasColumnType("text"); + + b.Property("Conveniences") + .HasColumnType("text"); + + b.Property("Design") + .HasColumnType("text"); + + b.Property("DetailOfBuilding") + .HasColumnType("text"); + + b.Property("Door") + .HasColumnType("text"); + + b.Property("ExpectedLifePeriodYears") + .HasColumnType("text"); + + b.Property("FloorFinisher") + .HasColumnType("text"); + + b.Property("FloorStructure") + .HasColumnType("text"); + + b.Property("FoundationStructure") + .HasColumnType("text"); + + b.Property("HandRail") + .HasColumnType("text"); + + b.Property("InspectionReportId") + .HasColumnType("integer"); + + b.Property("NatureOfConstruction") + .HasColumnType("text"); + + b.Property("NoOfFloorsAboveGround") + .HasColumnType("text") + .HasColumnName("NoOfFloorsAboveGround"); + + b.Property("NoOfFloorsBelowGround") + .HasColumnType("text") + .HasColumnName("NoOfFloorsBelowGround"); + + b.Property("OtherDoors") + .HasColumnType("text"); + + b.Property("PantryCupboard") + .HasColumnType("text"); + + b.Property("ParkingSpace") + .HasColumnType("text"); + + b.Property("RoofFinisher") + .HasColumnType("text"); + + b.Property("RoofFrame") + .HasColumnType("text"); + + b.Property("RoofMaterial") + .HasColumnType("text"); + + b.Property("Services") + .HasColumnType("text"); + + b.Property("Structure") + .HasColumnType("text"); + + b.Property("WallFinisher") + .HasColumnType("text"); + + b.Property("WallStructure") + .HasColumnType("text"); + + b.Property("Window") + .HasColumnType("text"); + + b.Property("WindowProtection") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InspectionReportId"); + + b.ToTable("InspectionBuildings"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionReport", b => + { + b.Property("InspectionReportId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("InspectionReportId")); + + b.Property("DetailsOfAssestsInventoryItems") + .HasColumnType("text") + .HasColumnName("DetailsOfAssestsInventoryItems"); + + b.Property("DetailsOfBusiness") + .HasColumnType("text"); + + b.Property("District") + .HasColumnType("text"); + + b.Property("DsDivision") + .HasColumnType("text"); + + b.Property("GnDivision") + .HasColumnType("text"); + + b.Property("InspectionDate") + .HasColumnType("timestamp with time zone"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherConstructionDetails") + .HasColumnType("text"); + + b.Property("OtherInformation") + .HasColumnType("text"); + + b.Property("Province") + .HasColumnType("text"); + + b.Property("Remark") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Village") + .HasColumnType("text"); + + b.HasKey("InspectionReportId"); + + b.HasIndex("ReportId"); + + b.ToTable("InspectionReports"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMBuildingRates", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNumber") + .HasColumnType("text"); + + b.Property("ConstructedBy") + .HasColumnType("text"); + + b.Property("Cost") + .HasColumnType("text"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("FloorArea") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePerSQFT") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("YearOfConstruction") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("LMBuildingRates"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMPastValuation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateOfValuation") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("FileNo_GnDivision") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanOfParticulars") + .HasColumnType("text"); + + b.Property("PurposeOfValuation") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("LMPastValuations"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMRentalEvidence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNo") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("FloorRate") + .HasColumnType("text"); + + b.Property("HeadOfTerms") + .HasColumnType("text"); + + b.Property("LandMiscellaneousMasterFileId") + .HasColumnType("integer"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePer") + .HasColumnType("text"); + + b.Property("RatePerMonth") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("LandMiscellaneousMasterFileId") + .HasDatabaseName("IX_LMRentalEvidence_LandMiscellaneousMasterFileId"); + + b.HasIndex("ReportId"); + + b.ToTable("LMRentalEvidences"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMSalesEvidence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNumber") + .HasColumnType("text"); + + b.Property("Consideration") + .HasColumnType("text"); + + b.Property("DeedAttestedNumber") + .HasColumnType("text"); + + b.Property("DeedNumber") + .HasColumnType("text"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("LandRegistryReferences") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("LotNumber") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("NotaryName") + .HasColumnType("text"); + + b.Property("PlanDate") + .HasColumnType("text"); + + b.Property("PlanNumber") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Road") + .HasColumnType("text"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("Vendor") + .HasColumnType("text"); + + b.Property("Village") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("LMSalesEvidences"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LandMiscellaneousMasterFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Lots") + .HasColumnType("integer"); + + b.Property("MasterFileNo") + .HasColumnType("integer"); + + b.Property("MasterFileRefNo") + .HasColumnType("text"); + + b.Property("PlanNo") + .HasColumnType("text"); + + b.Property("PlanType") + .HasColumnType("text"); + + b.Property("RequestingAuthorityReferenceNo") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LandMiscellaneousMasterFiles"); + }); + + modelBuilder.Entity("ValuationBackend.Models.MasterDataItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("MasterDataItems"); + }); + + modelBuilder.Entity("ValuationBackend.Models.PastValuationsLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfValuation") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("FileNoGNDivision") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanOfParticulars") + .HasColumnType("text"); + + b.Property("PurposeOfValuation") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("PastValuationsLA"); + }); + + modelBuilder.Entity("ValuationBackend.Models.PropertyCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("PropertyCategories"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RatingRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LocalAuthority") + .IsRequired() + .HasColumnType("text"); + + b.Property("RatingReferenceNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequestType") + .IsRequired() + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("YearOfRevision") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("RatingRequests"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Reconciliation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetId") + .HasColumnType("integer"); + + b.Property("NewNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ObsoleteNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("StreetName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AssetId"); + + b.ToTable("Reconciliations"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RentalEvidenceLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNo") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("FloorRateSQFT") + .HasColumnType("text"); + + b.Property("HeadOfTerms") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePerMonth") + .HasColumnType("text"); + + b.Property("RatePerSqft") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("RentalEvidencesLA", (string)null); + }); + + modelBuilder.Entity("ValuationBackend.Models.Report", b => + { + b.Property("ReportId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReportId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReportType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ReportId"); + + b.ToTable("Reports"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LocalAuthority") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("RatingReferenceNo") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("RequestTypeId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("boolean"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("YearOfRevision") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RequestTypeId"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RequestType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("character varying(2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("RequestTypes"); + }); + + modelBuilder.Entity("ValuationBackend.Models.SalesEvidenceLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNumber") + .HasColumnType("text"); + + b.Property("Consideration") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeedAttestedNumber") + .HasColumnType("text"); + + b.Property("DeedNumber") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("FloorRate") + .HasColumnType("text"); + + b.Property("LandRegistryReferences") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("LotNumber") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("NotaryName") + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("PlanDate") + .HasColumnType("text"); + + b.Property("PlanNumber") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Road") + .HasColumnType("text"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Vendor") + .HasColumnType("text"); + + b.Property("Village") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("SalesEvidencesLA", (string)null); + }); + + modelBuilder.Entity("ValuationBackend.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedDivision") + .IsRequired() + .HasColumnType("text"); + + b.Property("EmpEmail") + .IsRequired() + .HasColumnType("text"); + + b.Property("EmpId") + .IsRequired() + .HasColumnType("text"); + + b.Property("EmpName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("PasswordSalt") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("Position") + .IsRequired() + .HasColumnType("text"); + + b.Property("ProfilePicture") + .HasColumnType("bytea"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("ValuationBackend.Models.UserTask", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsCompleted") + .HasColumnType("boolean"); + + b.Property("LandAcquisitionId") + .HasColumnType("integer"); + + b.Property("LandMiscellaneousId") + .HasColumnType("integer"); + + b.Property("ReferenceNumber") + .HasColumnType("text"); + + b.Property("RequestId") + .HasColumnType("integer"); + + b.Property("TaskType") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkItemDescription") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserTasks"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Asset", b => + { + b.HasOne("ValuationBackend.Models.Request", "Request") + .WithMany() + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("ValuationBackend.Models.AssetDivision", b => + { + b.HasOne("ValuationBackend.Models.Asset", "Asset") + .WithMany() + .HasForeignKey("AssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Asset"); + }); + + modelBuilder.Entity("ValuationBackend.Models.BuildingRatesLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.ConditionReport", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.DomesticRatingCard", b => + { + b.HasOne("ValuationBackend.Models.Asset", "Asset") + .WithMany() + .HasForeignKey("AssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Asset"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionBuilding", b => + { + b.HasOne("ValuationBackend.Models.InspectionReport", "InspectionReport") + .WithMany("Buildings") + .HasForeignKey("InspectionReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionReport"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionReport", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMBuildingRates", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMPastValuation", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMRentalEvidence", b => + { + b.HasOne("ValuationBackend.Models.LandMiscellaneousMasterFile", "LandMiscellaneousMasterFile") + .WithMany("RentalEvidences") + .HasForeignKey("LandMiscellaneousMasterFileId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LandMiscellaneousMasterFile"); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMSalesEvidence", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.PastValuationsLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Reconciliation", b => + { + b.HasOne("ValuationBackend.Models.Asset", "Asset") + .WithMany() + .HasForeignKey("AssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Asset"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RentalEvidenceLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Request", b => + { + b.HasOne("ValuationBackend.Models.RequestType", "RequestType") + .WithMany() + .HasForeignKey("RequestTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RequestType"); + }); + + modelBuilder.Entity("ValuationBackend.Models.SalesEvidenceLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.UserTask", b => + { + b.HasOne("ValuationBackend.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionReport", b => + { + b.Navigation("Buildings"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LandMiscellaneousMasterFile", b => + { + b.Navigation("RentalEvidences"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20250722032612_AddLandMiscellaneousMasterFileIdToLMRentalEvidence.cs b/Migrations/20250722032612_AddLandMiscellaneousMasterFileIdToLMRentalEvidence.cs new file mode 100644 index 0000000..3767ed2 --- /dev/null +++ b/Migrations/20250722032612_AddLandMiscellaneousMasterFileIdToLMRentalEvidence.cs @@ -0,0 +1,49 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ValuationBackend.Migrations +{ + /// + public partial class AddLandMiscellaneousMasterFileIdToLMRentalEvidence : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LandMiscellaneousMasterFileId", + table: "LMRentalEvidences", + type: "integer", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_LMRentalEvidence_LandMiscellaneousMasterFileId", + table: "LMRentalEvidences", + column: "LandMiscellaneousMasterFileId"); + + migrationBuilder.AddForeignKey( + name: "FK_LMRentalEvidences_LandMiscellaneousMasterFiles_LandMiscella~", + table: "LMRentalEvidences", + column: "LandMiscellaneousMasterFileId", + principalTable: "LandMiscellaneousMasterFiles", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_LMRentalEvidences_LandMiscellaneousMasterFiles_LandMiscella~", + table: "LMRentalEvidences"); + + migrationBuilder.DropIndex( + name: "IX_LMRentalEvidence_LandMiscellaneousMasterFileId", + table: "LMRentalEvidences"); + + migrationBuilder.DropColumn( + name: "LandMiscellaneousMasterFileId", + table: "LMRentalEvidences"); + } + } +} diff --git a/Migrations/AppDbContextModelSnapshot.cs b/Migrations/AppDbContextModelSnapshot.cs index 41fc14b..8a0cdd9 100644 --- a/Migrations/AppDbContextModelSnapshot.cs +++ b/Migrations/AppDbContextModelSnapshot.cs @@ -835,6 +835,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("HeadOfTerms") .HasColumnType("text"); + b.Property("LandMiscellaneousMasterFileId") + .HasColumnType("integer"); + b.Property("LocationLatitude") .HasColumnType("text"); @@ -868,6 +871,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); + b.HasIndex("LandMiscellaneousMasterFileId") + .HasDatabaseName("IX_LMRentalEvidence_LandMiscellaneousMasterFileId"); + b.HasIndex("ReportId"); b.ToTable("LMRentalEvidences"); @@ -1617,12 +1623,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("ValuationBackend.Models.LMRentalEvidence", b => { + b.HasOne("ValuationBackend.Models.LandMiscellaneousMasterFile", "LandMiscellaneousMasterFile") + .WithMany("RentalEvidences") + .HasForeignKey("LandMiscellaneousMasterFileId") + .OnDelete(DeleteBehavior.SetNull); + b.HasOne("ValuationBackend.Models.Report", "Report") .WithMany() .HasForeignKey("ReportId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("LandMiscellaneousMasterFile"); + b.Navigation("Report"); }); @@ -1707,6 +1720,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Navigation("Buildings"); }); + + modelBuilder.Entity("ValuationBackend.Models.LandMiscellaneousMasterFile", b => + { + b.Navigation("RentalEvidences"); + }); #pragma warning restore 612, 618 } } diff --git a/Models/DTOs/LMRentalEvidenceDtos.cs b/Models/DTOs/LMRentalEvidenceDtos.cs index 8c1ad4d..7255af6 100644 --- a/Models/DTOs/LMRentalEvidenceDtos.cs +++ b/Models/DTOs/LMRentalEvidenceDtos.cs @@ -6,6 +6,10 @@ public class LMRentalEvidenceCreateDto { [Required] public string MasterFileRefNo { get; set; } + + // NEW: Optional foreign key to LandMiscellaneousMasterFile + public int? LandMiscellaneousMasterFileId { get; set; } + public string? AssessmentNo { get; set; } public string? Owner { get; set; } public string? Occupier { get; set; } @@ -26,6 +30,10 @@ public class LMRentalEvidenceUpdateDto public int ReportId { get; set; } [Required] public string MasterFileRefNo { get; set; } + + // NEW: Optional foreign key to LandMiscellaneousMasterFile + public int? LandMiscellaneousMasterFileId { get; set; } + public string? AssessmentNo { get; set; } public string? Owner { get; set; } public string? Occupier { get; set; } @@ -45,6 +53,13 @@ public class LMRentalEvidenceResponseDto public int Id { get; set; } public int ReportId { get; set; } public string MasterFileRefNo { get; set; } + + // NEW: Foreign key to LandMiscellaneousMasterFile + public int? LandMiscellaneousMasterFileId { get; set; } + + // NEW: Navigation property for related master file data + public LandMiscellaneousMasterFileDto? LandMiscellaneousMasterFile { get; set; } + public string? AssessmentNo { get; set; } public string? Owner { get; set; } public string? Occupier { get; set; } @@ -58,4 +73,17 @@ public class LMRentalEvidenceResponseDto public string? Situation { get; set; } public string? Remarks { get; set; } } + + // NEW: DTO for LandMiscellaneousMasterFile navigation property + public class LandMiscellaneousMasterFileDto + { + public int Id { get; set; } + public int MasterFileNo { get; set; } + public string? MasterFileRefNo { get; set; } + public string? PlanType { get; set; } + public string? PlanNo { get; set; } + public string? RequestingAuthorityReferenceNo { get; set; } + public string? Status { get; set; } + public int Lots { get; set; } + } } diff --git a/Models/LMRentalEvidence.cs b/Models/LMRentalEvidence.cs index d740a00..dec6747 100644 --- a/Models/LMRentalEvidence.cs +++ b/Models/LMRentalEvidence.cs @@ -14,10 +14,16 @@ public class LMRentalEvidence public int ReportId { get; set; } [ForeignKey("ReportId")] - public virtual Report Report { get; set; } + public virtual required Report Report { get; set; } [Required] - public string MasterFileRefNo { get; set; } + public required string MasterFileRefNo { get; set; } + + // NEW: Add foreign key to LandMiscellaneousMasterFile + public int? LandMiscellaneousMasterFileId { get; set; } + + [ForeignKey("LandMiscellaneousMasterFileId")] + public virtual LandMiscellaneousMasterFile? LandMiscellaneousMasterFile { get; set; } public string? AssessmentNo { get; set; } public string? Owner { get; set; } diff --git a/SORTING_API_DOCUMENTATION.md b/SORTING_API_DOCUMENTATION.md deleted file mode 100644 index 00608ea..0000000 --- a/SORTING_API_DOCUMENTATION.md +++ /dev/null @@ -1,85 +0,0 @@ -# Land Miscellaneous API - Sorting Documentation - -## Overview - -The Land Miscellaneous API endpoints now support sorting functionality. All sorting is performed in ascending order. - -## Available Endpoints with Sorting - -### 1. Get All Records with Sorting - -``` -GET /api/landmiscellaneous/all?sortBy={field} -``` - -### 2. Get Paginated Records with Sorting - -``` -GET /api/landmiscellaneous/paginated?pageNumber={number}&pageSize={size}&sortBy={field} -``` - -### 3. Search Records with Sorting - -``` -GET /api/landmiscellaneous/search?searchTerm={term}&pageNumber={number}&pageSize={size}&sortBy={field} -``` - -## Sortable Fields - -| Field Name | API Parameter | Description | -| --------------------------------- | -------------------------------- | --------------------------------------- | -| ID | `id` | Primary key | -| Master File No | `masterfileno` | Master file number | -| Plan Type | `plantype` | Type of plan (PP, Cadaster, FVP, etc.) | -| Plan No | `planno` | Plan number | -| Requesting Authority Reference No | `requestingauthorityreferenceno` | Reference number | -| Status | `status` | Current status (Success, Pending, etc.) | - -## Sort Direction - -All sorting is performed in **ascending order only**. - -## Examples - -### Sort by Master File Number - -``` -GET /api/landmiscellaneous/paginated?sortBy=masterfileno -``` - -### Sort by Status - -``` -GET /api/landmiscellaneous/all?sortBy=status -``` - -### Search with Sorting by Plan Type - -``` -GET /api/landmiscellaneous/search?searchTerm=PP&sortBy=plantype&pageNumber=1&pageSize=10 -``` - -## Default Behavior - -- If no `sortBy` parameter is provided, records are sorted by `Id` in ascending order -- If an invalid `sortBy` field is provided, it defaults to sorting by `Id` -- All sorting is performed in ascending order only - -## Response Format - -All responses include the sorting parameter in the response: - -```json -{ - "Records": [...], - "TotalCount": 100, - "PageNumber": 1, - "PageSize": 10, - "TotalPages": 10, - "SortBy": "masterfileno" -} -``` - -## Backward Compatibility - -All existing API calls will continue to work without any changes. The sorting parameter is optional and has sensible defaults. diff --git a/repositories/ILMRentalEvidenceRepository.cs b/repositories/ILMRentalEvidenceRepository.cs index 26e5bdd..077f2ae 100644 --- a/repositories/ILMRentalEvidenceRepository.cs +++ b/repositories/ILMRentalEvidenceRepository.cs @@ -9,6 +9,13 @@ public interface ILMRentalEvidenceRepository Task> GetAllAsync(); Task GetByIdAsync(int id); Task GetByReportIdAsync(int reportId); + + // NEW: Methods for foreign key relationship + Task> GetByMasterFileIdAsync(int masterFileId); + Task> GetByMasterFileRefNoAsync(string masterFileRefNo); + Task> GetAllWithMasterFileDataAsync(); + Task GetMasterFileByRefNoAsync(string refNo); + Task CreateReportAsync(Report report); Task CreateAsync(LMRentalEvidence lmRentalEvidence); Task UpdateAsync(LMRentalEvidence lmRentalEvidence); diff --git a/repositories/ILandMiscellaneousRepository.cs b/repositories/ILandMiscellaneousRepository.cs index 64733e7..8c81de6 100644 --- a/repositories/ILandMiscellaneousRepository.cs +++ b/repositories/ILandMiscellaneousRepository.cs @@ -13,5 +13,8 @@ public interface ILandMiscellaneousRepository Task> SearchAsync(string searchTerm, int pageNumber, int pageSize, string sortBy = "", int? assignedToUserId = null); Task GetSearchCountAsync(string searchTerm, int? assignedToUserId = null); + + // NEW: Method for foreign key support + Task GetByRefNoAsync(string refNo); } } diff --git a/repositories/LMRentalEvidenceRepository.cs b/repositories/LMRentalEvidenceRepository.cs index 5e97dba..e33c529 100644 --- a/repositories/LMRentalEvidenceRepository.cs +++ b/repositories/LMRentalEvidenceRepository.cs @@ -33,6 +33,36 @@ public async Task GetByReportIdAsync(int reportId) .FirstOrDefaultAsync(re => re.ReportId == reportId); } + // NEW: Methods for foreign key relationship + public async Task> GetByMasterFileIdAsync(int masterFileId) + { + return await _context.LMRentalEvidences + .Include(e => e.LandMiscellaneousMasterFile) + .Where(e => e.LandMiscellaneousMasterFileId == masterFileId) + .ToListAsync(); + } + + public async Task> GetByMasterFileRefNoAsync(string masterFileRefNo) + { + return await _context.LMRentalEvidences + .Include(e => e.LandMiscellaneousMasterFile) + .Where(e => e.MasterFileRefNo == masterFileRefNo) + .ToListAsync(); + } + + public async Task> GetAllWithMasterFileDataAsync() + { + return await _context.LMRentalEvidences + .Include(e => e.LandMiscellaneousMasterFile) + .ToListAsync(); + } + + public async Task GetMasterFileByRefNoAsync(string refNo) + { + return await _context.LandMiscellaneousMasterFiles + .FirstOrDefaultAsync(m => m.MasterFileRefNo == refNo); + } + public async Task CreateReportAsync(Report report) { report.Timestamp = DateTime.UtcNow; diff --git a/repositories/LandMiscellaneousRepository.cs b/repositories/LandMiscellaneousRepository.cs index ffda89b..f199b06 100644 --- a/repositories/LandMiscellaneousRepository.cs +++ b/repositories/LandMiscellaneousRepository.cs @@ -150,5 +150,12 @@ public async Task GetSearchCountAsync(string searchTerm, int? assignedToUse return await query.CountAsync(); } + + // NEW: Method for foreign key support + public async Task GetByRefNoAsync(string refNo) + { + return await _context.LandMiscellaneousMasterFiles + .FirstOrDefaultAsync(m => m.MasterFileRefNo == refNo); + } } } diff --git a/services/ILMRentalEvidenceService.cs b/services/ILMRentalEvidenceService.cs index 480fb4e..c83a7da 100644 --- a/services/ILMRentalEvidenceService.cs +++ b/services/ILMRentalEvidenceService.cs @@ -7,8 +7,14 @@ namespace ValuationBackend.Services public interface ILMRentalEvidenceService { Task> GetAllAsync(); - Task GetByIdAsync(int id); - Task GetByReportIdAsync(int reportId); + Task GetByIdAsync(int id); + Task GetByReportIdAsync(int reportId); + + // NEW: Methods for foreign key relationship + Task> GetByMasterFileIdAsync(int masterFileId); + Task> GetByMasterFileRefNoAsync(string masterFileRefNo); + Task> GetAllWithMasterFileDataAsync(); + Task CreateAsync(LMRentalEvidenceCreateDto dto); Task UpdateAsync(int reportId, LMRentalEvidenceUpdateDto dto); Task DeleteAsync(int id); diff --git a/services/LMRentalEvidenceService.cs b/services/LMRentalEvidenceService.cs index 95813dc..9530339 100644 --- a/services/LMRentalEvidenceService.cs +++ b/services/LMRentalEvidenceService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using ValuationBackend.Models; using ValuationBackend.Models.DTOs; using ValuationBackend.Repositories; @@ -11,10 +12,12 @@ namespace ValuationBackend.Services public class LMRentalEvidenceService : ILMRentalEvidenceService { private readonly ILMRentalEvidenceRepository _repository; + private readonly ILandMiscellaneousRepository _masterFileRepository; - public LMRentalEvidenceService(ILMRentalEvidenceRepository repository) + public LMRentalEvidenceService(ILMRentalEvidenceRepository repository, ILandMiscellaneousRepository masterFileRepository) { _repository = repository; + _masterFileRepository = masterFileRepository; } public async Task> GetAllAsync() @@ -23,18 +26,37 @@ public async Task> GetAllAsync() return lmRentalEvidences.Select(MapToResponseDto).ToList(); } - public async Task GetByIdAsync(int id) + public async Task GetByIdAsync(int id) { var lmRentalEvidence = await _repository.GetByIdAsync(id); return lmRentalEvidence == null ? null : MapToResponseDto(lmRentalEvidence); } - public async Task GetByReportIdAsync(int reportId) + public async Task GetByReportIdAsync(int reportId) { var lmRentalEvidence = await _repository.GetByReportIdAsync(reportId); return lmRentalEvidence == null ? null : MapToResponseDto(lmRentalEvidence); } + // NEW: Methods for foreign key relationship + public async Task> GetByMasterFileIdAsync(int masterFileId) + { + var evidences = await _repository.GetByMasterFileIdAsync(masterFileId); + return evidences.Select(MapToResponseDto).ToList(); + } + + public async Task> GetByMasterFileRefNoAsync(string masterFileRefNo) + { + var evidences = await _repository.GetByMasterFileRefNoAsync(masterFileRefNo); + return evidences.Select(MapToResponseDto).ToList(); + } + + public async Task> GetAllWithMasterFileDataAsync() + { + var evidences = await _repository.GetAllWithMasterFileDataAsync(); + return evidences.Select(MapToResponseDto).ToList(); + } + public async Task CreateAsync(LMRentalEvidenceCreateDto dto) { // Create a new Report for this LM rental evidence @@ -48,11 +70,12 @@ public async Task CreateAsync(LMRentalEvidenceCreat // Add the report first report = await _repository.CreateReportAsync(report); - // Create the LM rental evidence entity from the DTO - var lmRentalEvidence = new LMRentalEvidence + var entity = new LMRentalEvidence { ReportId = report.ReportId, + Report = report, MasterFileRefNo = dto.MasterFileRefNo, + LandMiscellaneousMasterFileId = dto.LandMiscellaneousMasterFileId, AssessmentNo = dto.AssessmentNo, Owner = dto.Owner, Occupier = dto.Occupier, @@ -67,8 +90,18 @@ public async Task CreateAsync(LMRentalEvidenceCreat Remarks = dto.Remarks }; - lmRentalEvidence = await _repository.CreateAsync(lmRentalEvidence); - return MapToResponseDto(lmRentalEvidence); + // Auto-populate foreign key if not provided but string reference exists + if (!entity.LandMiscellaneousMasterFileId.HasValue && !string.IsNullOrEmpty(entity.MasterFileRefNo)) + { + var masterFile = await _masterFileRepository.GetByRefNoAsync(entity.MasterFileRefNo); + if (masterFile != null) + { + entity.LandMiscellaneousMasterFileId = masterFile.Id; + } + } + + var createdEntity = await _repository.CreateAsync(entity); + return MapToResponseDto(createdEntity); } public async Task UpdateAsync(int reportId, LMRentalEvidenceUpdateDto dto) @@ -83,6 +116,7 @@ public async Task UpdateAsync(int reportId, LMRentalEvidenceUpdateDto dto) // Update existing LM rental evidence with data from DTO existingLMRentalEvidence.MasterFileRefNo = dto.MasterFileRefNo; + existingLMRentalEvidence.LandMiscellaneousMasterFileId = dto.LandMiscellaneousMasterFileId; existingLMRentalEvidence.AssessmentNo = dto.AssessmentNo; existingLMRentalEvidence.Owner = dto.Owner; existingLMRentalEvidence.Occupier = dto.Occupier; @@ -96,6 +130,16 @@ public async Task UpdateAsync(int reportId, LMRentalEvidenceUpdateDto dto) existingLMRentalEvidence.Situation = dto.Situation; existingLMRentalEvidence.Remarks = dto.Remarks; + // Auto-populate foreign key if not provided but string reference exists + if (!existingLMRentalEvidence.LandMiscellaneousMasterFileId.HasValue && !string.IsNullOrEmpty(existingLMRentalEvidence.MasterFileRefNo)) + { + var masterFile = await _masterFileRepository.GetByRefNoAsync(existingLMRentalEvidence.MasterFileRefNo); + if (masterFile != null) + { + existingLMRentalEvidence.LandMiscellaneousMasterFileId = masterFile.Id; + } + } + return await _repository.UpdateAsync(existingLMRentalEvidence); } @@ -111,6 +155,8 @@ private LMRentalEvidenceResponseDto MapToResponseDto(LMRentalEvidence lmRentalEv Id = lmRentalEvidence.Id, ReportId = lmRentalEvidence.ReportId, MasterFileRefNo = lmRentalEvidence.MasterFileRefNo, + LandMiscellaneousMasterFileId = lmRentalEvidence.LandMiscellaneousMasterFileId, + LandMiscellaneousMasterFile = lmRentalEvidence.LandMiscellaneousMasterFile != null ? MapMasterFileToDto(lmRentalEvidence.LandMiscellaneousMasterFile) : null, AssessmentNo = lmRentalEvidence.AssessmentNo, Owner = lmRentalEvidence.Owner, Occupier = lmRentalEvidence.Occupier, @@ -125,5 +171,20 @@ private LMRentalEvidenceResponseDto MapToResponseDto(LMRentalEvidence lmRentalEv Remarks = lmRentalEvidence.Remarks }; } + + private LandMiscellaneousMasterFileDto MapMasterFileToDto(LandMiscellaneousMasterFile masterFile) + { + return new LandMiscellaneousMasterFileDto + { + Id = masterFile.Id, + MasterFileNo = masterFile.MasterFileNo, + MasterFileRefNo = masterFile.MasterFileRefNo, + PlanType = masterFile.PlanType, + PlanNo = masterFile.PlanNo, + RequestingAuthorityReferenceNo = masterFile.RequestingAuthorityReferenceNo, + Status = masterFile.Status, + Lots = masterFile.Lots + }; + } } } From 67c46b333a7ae3a9680eed1ea334c0d707b61f22 Mon Sep 17 00:00:00 2001 From: Akith-002 Date: Tue, 22 Jul 2025 19:44:38 +0530 Subject: [PATCH 4/4] Add LandMiscellaneousMasterFileId to LM tables and update related DTOs, repositories, and services - Created a migration to add LandMiscellaneousMasterFileId to LMSalesEvidences, LMPastValuations, and LMBuildingRates tables. - Updated AppDbContextModelSnapshot to reflect new schema changes. - Modified LMBuildingRates, LMPastValuation, and LMSalesEvidence models to include LandMiscellaneousMasterFileId as a foreign key. - Enhanced DTOs for LMBuildingRates, LMPastValuation, and LMSalesEvidence to include LandMiscellaneousMasterFileId and related navigation properties. - Updated repositories to support fetching records by LandMiscellaneousMasterFileId and include related master file data. - Adjusted services to handle new methods for retrieving data based on LandMiscellaneousMasterFileId and to map master file details in response DTOs. --- Controllers/LMBuildingRatesController.cs | 8 + Controllers/LMPastValuationController.cs | 8 + Controllers/LMSalesEvidenceController.cs | 8 + Data/AppDbContext.cs | 33 + Extensions/ServiceExtensions.cs | 1 + ...llaneousMasterFileIdToLMTables.Designer.cs | 1768 +++++++++++++++++ ...LandMiscellaneousMasterFileIdToLMTables.cs | 111 ++ Migrations/AppDbContextModelSnapshot.cs | 46 +- Models/DTOs/LMBuildingRatesDtos.cs | 4 + Models/DTOs/LMPastValuationDtos.cs | 4 + Models/DTOs/LMSalesEvidenceDtos.cs | 4 + Models/LMBuildingRates.cs | 6 + Models/LMPastValuation.cs | 6 + Models/LMSalesEvidence.cs | 6 + repositories/ILMBuildingRatesRepository.cs | 2 + repositories/ILMPastValuationRepository.cs | 2 + repositories/ILMSalesEvidenceRepository.cs | 2 + repositories/LMBuildingRatesRepository.cs | 15 + repositories/LMPastValuationRepository.cs | 15 + repositories/LMSalesEvidenceRepository.cs | 15 + services/ILMBuildingRatesService.cs | 1 + services/ILMPastValuationService.cs | 1 + services/ILMSalesEvidenceService.cs | 1 + services/LMBuildingRatesService.cs | 33 +- services/LMPastValuationService.cs | 33 +- services/LMSalesEvidenceService.cs | 33 +- 26 files changed, 2151 insertions(+), 15 deletions(-) create mode 100644 Migrations/20250722064047_AddLandMiscellaneousMasterFileIdToLMTables.Designer.cs create mode 100644 Migrations/20250722064047_AddLandMiscellaneousMasterFileIdToLMTables.cs diff --git a/Controllers/LMBuildingRatesController.cs b/Controllers/LMBuildingRatesController.cs index 597426f..7d03416 100644 --- a/Controllers/LMBuildingRatesController.cs +++ b/Controllers/LMBuildingRatesController.cs @@ -81,5 +81,13 @@ public async Task> GetLMBuildingRateByR return lmBuildingRate; } + + // GET: api/LMBuildingRates/ByMasterFile/5 + [HttpGet("ByMasterFile/{masterFileId}")] + public async Task>> GetLMBuildingRatesByMasterFileId(int masterFileId) + { + var buildingRates = await _lmBuildingRatesService.GetByMasterFileIdAsync(masterFileId); + return Ok(buildingRates); + } } } diff --git a/Controllers/LMPastValuationController.cs b/Controllers/LMPastValuationController.cs index 5059497..921271e 100644 --- a/Controllers/LMPastValuationController.cs +++ b/Controllers/LMPastValuationController.cs @@ -93,5 +93,13 @@ public async Task> GetLMPastValuationBy return lmPastValuation; } + + // GET: api/LMPastValuation/ByMasterFile/5 + [HttpGet("ByMasterFile/{masterFileId}")] + public async Task>> GetLMPastValuationsByMasterFileId(int masterFileId) + { + var pastValuations = await _lmPastValuationService.GetByMasterFileIdAsync(masterFileId); + return Ok(pastValuations); + } } } diff --git a/Controllers/LMSalesEvidenceController.cs b/Controllers/LMSalesEvidenceController.cs index 3f357e5..db1a456 100644 --- a/Controllers/LMSalesEvidenceController.cs +++ b/Controllers/LMSalesEvidenceController.cs @@ -93,5 +93,13 @@ public async Task> GetLMSalesEvidenceBy return lmSalesEvidence; } + + // GET: api/LMSalesEvidence/ByMasterFile/5 + [HttpGet("ByMasterFile/{masterFileId}")] + public async Task>> GetLMSalesEvidencesByMasterFileId(int masterFileId) + { + var salesEvidences = await _lmSalesEvidenceService.GetByMasterFileIdAsync(masterFileId); + return Ok(salesEvidences); + } } } diff --git a/Data/AppDbContext.cs b/Data/AppDbContext.cs index 864dbad..79b24af 100644 --- a/Data/AppDbContext.cs +++ b/Data/AppDbContext.cs @@ -82,6 +82,39 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity() .HasIndex(lm => lm.LandMiscellaneousMasterFileId) .HasDatabaseName("IX_LMRentalEvidence_LandMiscellaneousMasterFileId"); + + // Configure LMBuildingRates relationships + modelBuilder.Entity() + .HasOne(lm => lm.LandMiscellaneousMasterFile) + .WithMany() // No navigation property on master file side + .HasForeignKey(lm => lm.LandMiscellaneousMasterFileId) + .OnDelete(DeleteBehavior.SetNull); + + modelBuilder.Entity() + .HasIndex(lm => lm.LandMiscellaneousMasterFileId) + .HasDatabaseName("IX_LMBuildingRates_LandMiscellaneousMasterFileId"); + + // Configure LMPastValuation relationships + modelBuilder.Entity() + .HasOne(lm => lm.LandMiscellaneousMasterFile) + .WithMany() // No navigation property on master file side + .HasForeignKey(lm => lm.LandMiscellaneousMasterFileId) + .OnDelete(DeleteBehavior.SetNull); + + modelBuilder.Entity() + .HasIndex(lm => lm.LandMiscellaneousMasterFileId) + .HasDatabaseName("IX_LMPastValuation_LandMiscellaneousMasterFileId"); + + // Configure LMSalesEvidence relationships + modelBuilder.Entity() + .HasOne(lm => lm.LandMiscellaneousMasterFile) + .WithMany() // No navigation property on master file side + .HasForeignKey(lm => lm.LandMiscellaneousMasterFileId) + .OnDelete(DeleteBehavior.SetNull); + + modelBuilder.Entity() + .HasIndex(lm => lm.LandMiscellaneousMasterFileId) + .HasDatabaseName("IX_LMSalesEvidence_LandMiscellaneousMasterFileId"); } } } diff --git a/Extensions/ServiceExtensions.cs b/Extensions/ServiceExtensions.cs index 4e4bf45..ef2e473 100644 --- a/Extensions/ServiceExtensions.cs +++ b/Extensions/ServiceExtensions.cs @@ -14,6 +14,7 @@ public static IServiceCollection AddServices(this IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/Migrations/20250722064047_AddLandMiscellaneousMasterFileIdToLMTables.Designer.cs b/Migrations/20250722064047_AddLandMiscellaneousMasterFileIdToLMTables.Designer.cs new file mode 100644 index 0000000..e5d2a65 --- /dev/null +++ b/Migrations/20250722064047_AddLandMiscellaneousMasterFileIdToLMTables.Designer.cs @@ -0,0 +1,1768 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using ValuationBackend.Data; + +#nullable disable + +namespace ValuationBackend.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20250722064047_AddLandMiscellaneousMasterFileIdToLMTables")] + partial class AddLandMiscellaneousMasterFileIdToLMTables + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LandAquisitionMasterFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("MasterFileNo") + .HasColumnType("integer"); + + b.Property("MasterFilesRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanType") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequestingAuthorityReferenceNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LandAquisitionMasterFiles"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Asset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNo") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("integer"); + + b.Property("IsRatingCard") + .HasColumnType("boolean"); + + b.Property("Owner") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("RdSt") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("RequestId") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Ward") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("RequestId"); + + b.ToTable("Assets"); + }); + + modelBuilder.Entity("ValuationBackend.Models.AssetDivision", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Area") + .HasColumnType("numeric"); + + b.Property("AssetId") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("LandType") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("NewAssetNo") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AssetId"); + + b.ToTable("AssetDivisions"); + }); + + modelBuilder.Entity("ValuationBackend.Models.AssetNumberChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChangedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfChange") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("FieldSize") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("FieldType") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("NewAssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OldAssetNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Reason") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("AssetNumberChanges"); + }); + + modelBuilder.Entity("ValuationBackend.Models.BuildingRatesLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNumber") + .HasColumnType("text"); + + b.Property("ConstructedBy") + .HasColumnType("text"); + + b.Property("Cost") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("FloorAreaSQFT") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePerSQFT") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("YearOfConstruction") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("BuildingRatesLA"); + }); + + modelBuilder.Entity("ValuationBackend.Models.ConditionReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccessCategory") + .IsRequired() + .HasColumnType("text"); + + b.Property("AccessCategoryDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("AcquiredExtent") + .IsRequired() + .HasColumnType("text"); + + b.Property("AcquiringOfficerSignature") + .IsRequired() + .HasColumnType("text"); + + b.Property("AcquisitionName") + .IsRequired() + .HasColumnType("text"); + + b.Property("AssessmentNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("AtLotNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("AtPlanNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryBottom") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryEast") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryNorth") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundarySouth") + .IsRequired() + .HasColumnType("text"); + + b.Property("BoundaryWest") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingInfo") + .IsRequired() + .HasColumnType("text"); + + b.Property("ChiefValuerRepresentativeSignature") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfSection3BA") + .IsRequired() + .HasColumnType("text"); + + b.Property("DatePrepared") + .IsRequired() + .HasColumnType("text"); + + b.Property("DepthOfLand") + .IsRequired() + .HasColumnType("text"); + + b.Property("DescriptionOfLand") + .IsRequired() + .HasColumnType("text"); + + b.Property("DetailsOfBusiness") + .IsRequired() + .HasColumnType("text"); + + b.Property("Frontage") + .IsRequired() + .HasColumnType("text"); + + b.Property("GramasewakaSignature") + .IsRequired() + .HasColumnType("text"); + + b.Property("LandUseDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("LandUseType") + .IsRequired() + .HasColumnType("text"); + + b.Property("LevelWithAccess") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameOfTheLand") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameOfTheVillage") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherConstructionsDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherConstructionsInfo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlantationDetails") + .IsRequired() + .HasColumnType("text"); + + b.Property("PpCadLotNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("PpCadNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("RoadName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("ConditionReports"); + }); + + modelBuilder.Entity("ValuationBackend.Models.DomesticRatingCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Access") + .HasColumnType("text"); + + b.Property("Age") + .HasColumnType("integer"); + + b.Property("AssetId") + .HasColumnType("integer"); + + b.Property("Condition") + .HasColumnType("text"); + + b.Property("Conveniences") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Floor") + .HasColumnType("text"); + + b.Property("NewNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("Notes") + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParkingSpace") + .HasColumnType("text"); + + b.Property("Plantations") + .HasColumnType("text"); + + b.Property("PropertySubCategory") + .HasColumnType("text"); + + b.Property("PropertyType") + .HasColumnType("text"); + + b.Property("RentPM") + .HasColumnType("numeric"); + + b.Property("RoadName") + .HasColumnType("text"); + + b.Property("SelectWalls") + .HasColumnType("text"); + + b.Property("SuggestedRate") + .HasColumnType("numeric"); + + b.Property("Terms") + .HasColumnType("text"); + + b.Property("TsBop") + .HasColumnType("text"); + + b.Property("WardNumber") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AssetId"); + + b.ToTable("DomesticRatingCards"); + }); + + modelBuilder.Entity("ValuationBackend.Models.ImageData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ImageBase64") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("ImageData"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionBuilding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AgeYears") + .HasColumnType("text"); + + b.Property("BathroomToilet") + .HasColumnType("text"); + + b.Property("BathroomToiletDoorsFittings") + .HasColumnType("text"); + + b.Property("BuildingCategory") + .HasColumnType("text"); + + b.Property("BuildingClass") + .HasColumnType("text"); + + b.Property("BuildingConditions") + .HasColumnType("text"); + + b.Property("BuildingId") + .HasColumnType("text"); + + b.Property("BuildingName") + .HasColumnType("text"); + + b.Property("Ceiling") + .HasColumnType("text"); + + b.Property("Condition") + .HasColumnType("text"); + + b.Property("Conveniences") + .HasColumnType("text"); + + b.Property("Design") + .HasColumnType("text"); + + b.Property("DetailOfBuilding") + .HasColumnType("text"); + + b.Property("Door") + .HasColumnType("text"); + + b.Property("ExpectedLifePeriodYears") + .HasColumnType("text"); + + b.Property("FloorFinisher") + .HasColumnType("text"); + + b.Property("FloorStructure") + .HasColumnType("text"); + + b.Property("FoundationStructure") + .HasColumnType("text"); + + b.Property("HandRail") + .HasColumnType("text"); + + b.Property("InspectionReportId") + .HasColumnType("integer"); + + b.Property("NatureOfConstruction") + .HasColumnType("text"); + + b.Property("NoOfFloorsAboveGround") + .HasColumnType("text") + .HasColumnName("NoOfFloorsAboveGround"); + + b.Property("NoOfFloorsBelowGround") + .HasColumnType("text") + .HasColumnName("NoOfFloorsBelowGround"); + + b.Property("OtherDoors") + .HasColumnType("text"); + + b.Property("PantryCupboard") + .HasColumnType("text"); + + b.Property("ParkingSpace") + .HasColumnType("text"); + + b.Property("RoofFinisher") + .HasColumnType("text"); + + b.Property("RoofFrame") + .HasColumnType("text"); + + b.Property("RoofMaterial") + .HasColumnType("text"); + + b.Property("Services") + .HasColumnType("text"); + + b.Property("Structure") + .HasColumnType("text"); + + b.Property("WallFinisher") + .HasColumnType("text"); + + b.Property("WallStructure") + .HasColumnType("text"); + + b.Property("Window") + .HasColumnType("text"); + + b.Property("WindowProtection") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InspectionReportId"); + + b.ToTable("InspectionBuildings"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionReport", b => + { + b.Property("InspectionReportId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("InspectionReportId")); + + b.Property("DetailsOfAssestsInventoryItems") + .HasColumnType("text") + .HasColumnName("DetailsOfAssestsInventoryItems"); + + b.Property("DetailsOfBusiness") + .HasColumnType("text"); + + b.Property("District") + .HasColumnType("text"); + + b.Property("DsDivision") + .HasColumnType("text"); + + b.Property("GnDivision") + .HasColumnType("text"); + + b.Property("InspectionDate") + .HasColumnType("timestamp with time zone"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherConstructionDetails") + .HasColumnType("text"); + + b.Property("OtherInformation") + .HasColumnType("text"); + + b.Property("Province") + .HasColumnType("text"); + + b.Property("Remark") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Village") + .HasColumnType("text"); + + b.HasKey("InspectionReportId"); + + b.HasIndex("ReportId"); + + b.ToTable("InspectionReports"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMBuildingRates", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNumber") + .HasColumnType("text"); + + b.Property("ConstructedBy") + .HasColumnType("text"); + + b.Property("Cost") + .HasColumnType("text"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("FloorArea") + .HasColumnType("text"); + + b.Property("LandMiscellaneousMasterFileId") + .HasColumnType("integer"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePerSQFT") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("YearOfConstruction") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("LandMiscellaneousMasterFileId") + .HasDatabaseName("IX_LMBuildingRates_LandMiscellaneousMasterFileId"); + + b.HasIndex("ReportId"); + + b.ToTable("LMBuildingRates"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMPastValuation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateOfValuation") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("FileNo_GnDivision") + .HasColumnType("text"); + + b.Property("LandMiscellaneousMasterFileId") + .HasColumnType("integer"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanOfParticulars") + .HasColumnType("text"); + + b.Property("PurposeOfValuation") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("LandMiscellaneousMasterFileId") + .HasDatabaseName("IX_LMPastValuation_LandMiscellaneousMasterFileId"); + + b.HasIndex("ReportId"); + + b.ToTable("LMPastValuations"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMRentalEvidence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNo") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("FloorRate") + .HasColumnType("text"); + + b.Property("HeadOfTerms") + .HasColumnType("text"); + + b.Property("LandMiscellaneousMasterFileId") + .HasColumnType("integer"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePer") + .HasColumnType("text"); + + b.Property("RatePerMonth") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("LandMiscellaneousMasterFileId") + .HasDatabaseName("IX_LMRentalEvidence_LandMiscellaneousMasterFileId"); + + b.HasIndex("ReportId"); + + b.ToTable("LMRentalEvidences"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMSalesEvidence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNumber") + .HasColumnType("text"); + + b.Property("Consideration") + .HasColumnType("text"); + + b.Property("DeedAttestedNumber") + .HasColumnType("text"); + + b.Property("DeedNumber") + .HasColumnType("text"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("LandMiscellaneousMasterFileId") + .HasColumnType("integer"); + + b.Property("LandRegistryReferences") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("LotNumber") + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("NotaryName") + .HasColumnType("text"); + + b.Property("PlanDate") + .HasColumnType("text"); + + b.Property("PlanNumber") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Road") + .HasColumnType("text"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("Vendor") + .HasColumnType("text"); + + b.Property("Village") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("LandMiscellaneousMasterFileId") + .HasDatabaseName("IX_LMSalesEvidence_LandMiscellaneousMasterFileId"); + + b.HasIndex("ReportId"); + + b.ToTable("LMSalesEvidences"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LandMiscellaneousMasterFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Lots") + .HasColumnType("integer"); + + b.Property("MasterFileNo") + .HasColumnType("integer"); + + b.Property("MasterFileRefNo") + .HasColumnType("text"); + + b.Property("PlanNo") + .HasColumnType("text"); + + b.Property("PlanType") + .HasColumnType("text"); + + b.Property("RequestingAuthorityReferenceNo") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("LandMiscellaneousMasterFiles"); + }); + + modelBuilder.Entity("ValuationBackend.Models.MasterDataItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("MasterDataItems"); + }); + + modelBuilder.Entity("ValuationBackend.Models.PastValuationsLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOfValuation") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("FileNoGNDivision") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanOfParticulars") + .HasColumnType("text"); + + b.Property("PurposeOfValuation") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("PastValuationsLA"); + }); + + modelBuilder.Entity("ValuationBackend.Models.PropertyCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("PropertyCategories"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RatingRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LocalAuthority") + .IsRequired() + .HasColumnType("text"); + + b.Property("RatingReferenceNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequestType") + .IsRequired() + .HasColumnType("text"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("YearOfRevision") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("RatingRequests"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Reconciliation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetId") + .HasColumnType("integer"); + + b.Property("NewNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ObsoleteNo") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("StreetName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AssetId"); + + b.ToTable("Reconciliations"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RentalEvidenceLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssessmentNo") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("FloorRateSQFT") + .HasColumnType("text"); + + b.Property("HeadOfTerms") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("RatePerMonth") + .HasColumnType("text"); + + b.Property("RatePerSqft") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("RentalEvidencesLA", (string)null); + }); + + modelBuilder.Entity("ValuationBackend.Models.Report", b => + { + b.Property("ReportId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ReportId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReportType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ReportId"); + + b.ToTable("Reports"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LocalAuthority") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("RatingReferenceNo") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("RequestTypeId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("boolean"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("YearOfRevision") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RequestTypeId"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RequestType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("character varying(2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.ToTable("RequestTypes"); + }); + + modelBuilder.Entity("ValuationBackend.Models.SalesEvidenceLA", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssetNumber") + .HasColumnType("text"); + + b.Property("Consideration") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeedAttestedNumber") + .HasColumnType("text"); + + b.Property("DeedNumber") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("DescriptionOfProperty") + .HasColumnType("text"); + + b.Property("Extent") + .HasColumnType("text"); + + b.Property("FloorRate") + .HasColumnType("text"); + + b.Property("LandRegistryReferences") + .HasColumnType("text"); + + b.Property("LocationLatitude") + .HasColumnType("text"); + + b.Property("LocationLongitude") + .HasColumnType("text"); + + b.Property("LotNumber") + .HasColumnType("text"); + + b.Property("MasterFileId") + .IsRequired() + .HasColumnType("text"); + + b.Property("MasterFileRefNo") + .IsRequired() + .HasColumnType("text"); + + b.Property("NotaryName") + .HasColumnType("text"); + + b.Property("Occupier") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("PlanDate") + .HasColumnType("text"); + + b.Property("PlanNumber") + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("text"); + + b.Property("RateType") + .HasColumnType("text"); + + b.Property("Remarks") + .HasColumnType("text"); + + b.Property("ReportId") + .HasColumnType("integer"); + + b.Property("Road") + .HasColumnType("text"); + + b.Property("Situation") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Vendor") + .HasColumnType("text"); + + b.Property("Village") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ReportId"); + + b.ToTable("SalesEvidencesLA", (string)null); + }); + + modelBuilder.Entity("ValuationBackend.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedDivision") + .IsRequired() + .HasColumnType("text"); + + b.Property("EmpEmail") + .IsRequired() + .HasColumnType("text"); + + b.Property("EmpId") + .IsRequired() + .HasColumnType("text"); + + b.Property("EmpName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("PasswordSalt") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("Position") + .IsRequired() + .HasColumnType("text"); + + b.Property("ProfilePicture") + .HasColumnType("bytea"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("ValuationBackend.Models.UserTask", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsCompleted") + .HasColumnType("boolean"); + + b.Property("LandAcquisitionId") + .HasColumnType("integer"); + + b.Property("LandMiscellaneousId") + .HasColumnType("integer"); + + b.Property("ReferenceNumber") + .HasColumnType("text"); + + b.Property("RequestId") + .HasColumnType("integer"); + + b.Property("TaskType") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkItemDescription") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserTasks"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Asset", b => + { + b.HasOne("ValuationBackend.Models.Request", "Request") + .WithMany() + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("ValuationBackend.Models.AssetDivision", b => + { + b.HasOne("ValuationBackend.Models.Asset", "Asset") + .WithMany() + .HasForeignKey("AssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Asset"); + }); + + modelBuilder.Entity("ValuationBackend.Models.BuildingRatesLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.ConditionReport", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.DomesticRatingCard", b => + { + b.HasOne("ValuationBackend.Models.Asset", "Asset") + .WithMany() + .HasForeignKey("AssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Asset"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionBuilding", b => + { + b.HasOne("ValuationBackend.Models.InspectionReport", "InspectionReport") + .WithMany("Buildings") + .HasForeignKey("InspectionReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionReport"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionReport", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMBuildingRates", b => + { + b.HasOne("ValuationBackend.Models.LandMiscellaneousMasterFile", "LandMiscellaneousMasterFile") + .WithMany() + .HasForeignKey("LandMiscellaneousMasterFileId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LandMiscellaneousMasterFile"); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMPastValuation", b => + { + b.HasOne("ValuationBackend.Models.LandMiscellaneousMasterFile", "LandMiscellaneousMasterFile") + .WithMany() + .HasForeignKey("LandMiscellaneousMasterFileId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LandMiscellaneousMasterFile"); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMRentalEvidence", b => + { + b.HasOne("ValuationBackend.Models.LandMiscellaneousMasterFile", "LandMiscellaneousMasterFile") + .WithMany() + .HasForeignKey("LandMiscellaneousMasterFileId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LandMiscellaneousMasterFile"); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.LMSalesEvidence", b => + { + b.HasOne("ValuationBackend.Models.LandMiscellaneousMasterFile", "LandMiscellaneousMasterFile") + .WithMany() + .HasForeignKey("LandMiscellaneousMasterFileId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LandMiscellaneousMasterFile"); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.PastValuationsLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Reconciliation", b => + { + b.HasOne("ValuationBackend.Models.Asset", "Asset") + .WithMany() + .HasForeignKey("AssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Asset"); + }); + + modelBuilder.Entity("ValuationBackend.Models.RentalEvidenceLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.Request", b => + { + b.HasOne("ValuationBackend.Models.RequestType", "RequestType") + .WithMany() + .HasForeignKey("RequestTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RequestType"); + }); + + modelBuilder.Entity("ValuationBackend.Models.SalesEvidenceLA", b => + { + b.HasOne("ValuationBackend.Models.Report", "Report") + .WithMany() + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("ValuationBackend.Models.UserTask", b => + { + b.HasOne("ValuationBackend.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("ValuationBackend.Models.InspectionReport", b => + { + b.Navigation("Buildings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20250722064047_AddLandMiscellaneousMasterFileIdToLMTables.cs b/Migrations/20250722064047_AddLandMiscellaneousMasterFileIdToLMTables.cs new file mode 100644 index 0000000..bcf1fea --- /dev/null +++ b/Migrations/20250722064047_AddLandMiscellaneousMasterFileIdToLMTables.cs @@ -0,0 +1,111 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ValuationBackend.Migrations +{ + /// + public partial class AddLandMiscellaneousMasterFileIdToLMTables : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LandMiscellaneousMasterFileId", + table: "LMSalesEvidences", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "LandMiscellaneousMasterFileId", + table: "LMPastValuations", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "LandMiscellaneousMasterFileId", + table: "LMBuildingRates", + type: "integer", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_LMSalesEvidence_LandMiscellaneousMasterFileId", + table: "LMSalesEvidences", + column: "LandMiscellaneousMasterFileId"); + + migrationBuilder.CreateIndex( + name: "IX_LMPastValuation_LandMiscellaneousMasterFileId", + table: "LMPastValuations", + column: "LandMiscellaneousMasterFileId"); + + migrationBuilder.CreateIndex( + name: "IX_LMBuildingRates_LandMiscellaneousMasterFileId", + table: "LMBuildingRates", + column: "LandMiscellaneousMasterFileId"); + + migrationBuilder.AddForeignKey( + name: "FK_LMBuildingRates_LandMiscellaneousMasterFiles_LandMiscellane~", + table: "LMBuildingRates", + column: "LandMiscellaneousMasterFileId", + principalTable: "LandMiscellaneousMasterFiles", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + + migrationBuilder.AddForeignKey( + name: "FK_LMPastValuations_LandMiscellaneousMasterFiles_LandMiscellan~", + table: "LMPastValuations", + column: "LandMiscellaneousMasterFileId", + principalTable: "LandMiscellaneousMasterFiles", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + + migrationBuilder.AddForeignKey( + name: "FK_LMSalesEvidences_LandMiscellaneousMasterFiles_LandMiscellan~", + table: "LMSalesEvidences", + column: "LandMiscellaneousMasterFileId", + principalTable: "LandMiscellaneousMasterFiles", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_LMBuildingRates_LandMiscellaneousMasterFiles_LandMiscellane~", + table: "LMBuildingRates"); + + migrationBuilder.DropForeignKey( + name: "FK_LMPastValuations_LandMiscellaneousMasterFiles_LandMiscellan~", + table: "LMPastValuations"); + + migrationBuilder.DropForeignKey( + name: "FK_LMSalesEvidences_LandMiscellaneousMasterFiles_LandMiscellan~", + table: "LMSalesEvidences"); + + migrationBuilder.DropIndex( + name: "IX_LMSalesEvidence_LandMiscellaneousMasterFileId", + table: "LMSalesEvidences"); + + migrationBuilder.DropIndex( + name: "IX_LMPastValuation_LandMiscellaneousMasterFileId", + table: "LMPastValuations"); + + migrationBuilder.DropIndex( + name: "IX_LMBuildingRates_LandMiscellaneousMasterFileId", + table: "LMBuildingRates"); + + migrationBuilder.DropColumn( + name: "LandMiscellaneousMasterFileId", + table: "LMSalesEvidences"); + + migrationBuilder.DropColumn( + name: "LandMiscellaneousMasterFileId", + table: "LMPastValuations"); + + migrationBuilder.DropColumn( + name: "LandMiscellaneousMasterFileId", + table: "LMBuildingRates"); + } + } +} diff --git a/Migrations/AppDbContextModelSnapshot.cs b/Migrations/AppDbContextModelSnapshot.cs index 8a0cdd9..ed2b7c9 100644 --- a/Migrations/AppDbContextModelSnapshot.cs +++ b/Migrations/AppDbContextModelSnapshot.cs @@ -728,6 +728,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("FloorArea") .HasColumnType("text"); + b.Property("LandMiscellaneousMasterFileId") + .HasColumnType("integer"); + b.Property("LocationLatitude") .HasColumnType("text"); @@ -755,6 +758,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); + b.HasIndex("LandMiscellaneousMasterFileId") + .HasDatabaseName("IX_LMBuildingRates_LandMiscellaneousMasterFileId"); + b.HasIndex("ReportId"); b.ToTable("LMBuildingRates"); @@ -777,6 +783,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("FileNo_GnDivision") .HasColumnType("text"); + b.Property("LandMiscellaneousMasterFileId") + .HasColumnType("integer"); + b.Property("LocationLatitude") .HasColumnType("text"); @@ -810,6 +819,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); + b.HasIndex("LandMiscellaneousMasterFileId") + .HasDatabaseName("IX_LMPastValuation_LandMiscellaneousMasterFileId"); + b.HasIndex("ReportId"); b.ToTable("LMPastValuations"); @@ -905,6 +917,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Extent") .HasColumnType("text"); + b.Property("LandMiscellaneousMasterFileId") + .HasColumnType("integer"); + b.Property("LandRegistryReferences") .HasColumnType("text"); @@ -956,6 +971,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); + b.HasIndex("LandMiscellaneousMasterFileId") + .HasDatabaseName("IX_LMSalesEvidence_LandMiscellaneousMasterFileId"); + b.HasIndex("ReportId"); b.ToTable("LMSalesEvidences"); @@ -1601,30 +1619,44 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("ValuationBackend.Models.LMBuildingRates", b => { + b.HasOne("ValuationBackend.Models.LandMiscellaneousMasterFile", "LandMiscellaneousMasterFile") + .WithMany() + .HasForeignKey("LandMiscellaneousMasterFileId") + .OnDelete(DeleteBehavior.SetNull); + b.HasOne("ValuationBackend.Models.Report", "Report") .WithMany() .HasForeignKey("ReportId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("LandMiscellaneousMasterFile"); + b.Navigation("Report"); }); modelBuilder.Entity("ValuationBackend.Models.LMPastValuation", b => { + b.HasOne("ValuationBackend.Models.LandMiscellaneousMasterFile", "LandMiscellaneousMasterFile") + .WithMany() + .HasForeignKey("LandMiscellaneousMasterFileId") + .OnDelete(DeleteBehavior.SetNull); + b.HasOne("ValuationBackend.Models.Report", "Report") .WithMany() .HasForeignKey("ReportId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("LandMiscellaneousMasterFile"); + b.Navigation("Report"); }); modelBuilder.Entity("ValuationBackend.Models.LMRentalEvidence", b => { b.HasOne("ValuationBackend.Models.LandMiscellaneousMasterFile", "LandMiscellaneousMasterFile") - .WithMany("RentalEvidences") + .WithMany() .HasForeignKey("LandMiscellaneousMasterFileId") .OnDelete(DeleteBehavior.SetNull); @@ -1641,12 +1673,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("ValuationBackend.Models.LMSalesEvidence", b => { + b.HasOne("ValuationBackend.Models.LandMiscellaneousMasterFile", "LandMiscellaneousMasterFile") + .WithMany() + .HasForeignKey("LandMiscellaneousMasterFileId") + .OnDelete(DeleteBehavior.SetNull); + b.HasOne("ValuationBackend.Models.Report", "Report") .WithMany() .HasForeignKey("ReportId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("LandMiscellaneousMasterFile"); + b.Navigation("Report"); }); @@ -1720,11 +1759,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Navigation("Buildings"); }); - - modelBuilder.Entity("ValuationBackend.Models.LandMiscellaneousMasterFile", b => - { - b.Navigation("RentalEvidences"); - }); #pragma warning restore 612, 618 } } diff --git a/Models/DTOs/LMBuildingRatesDtos.cs b/Models/DTOs/LMBuildingRatesDtos.cs index cbc37ce..7fb7a80 100644 --- a/Models/DTOs/LMBuildingRatesDtos.cs +++ b/Models/DTOs/LMBuildingRatesDtos.cs @@ -17,6 +17,7 @@ public class LMBuildingRatesCreateDto public string? Remarks { get; set; } public string? LocationLatitude { get; set; } public string? LocationLongitude { get; set; } + public int? LandMiscellaneousMasterFileId { get; set; } } public class LMBuildingRatesUpdateDto @@ -36,6 +37,7 @@ public class LMBuildingRatesUpdateDto public string? Remarks { get; set; } public string? LocationLatitude { get; set; } public string? LocationLongitude { get; set; } + public int? LandMiscellaneousMasterFileId { get; set; } } public class LMBuildingRatesResponseDto @@ -54,5 +56,7 @@ public class LMBuildingRatesResponseDto public string? Remarks { get; set; } public string? LocationLatitude { get; set; } public string? LocationLongitude { get; set; } + public int? LandMiscellaneousMasterFileId { get; set; } + public LandMiscellaneousMasterFileDto? LandMiscellaneousMasterFile { get; set; } } } diff --git a/Models/DTOs/LMPastValuationDtos.cs b/Models/DTOs/LMPastValuationDtos.cs index 70e952c..58afd7f 100644 --- a/Models/DTOs/LMPastValuationDtos.cs +++ b/Models/DTOs/LMPastValuationDtos.cs @@ -17,6 +17,7 @@ public class LMPastValuationCreateDto public string? Remarks { get; set; } public string? LocationLongitude { get; set; } public string? LocationLatitude { get; set; } + public int? LandMiscellaneousMasterFileId { get; set; } } public class LMPastValuationUpdateDto @@ -36,6 +37,7 @@ public class LMPastValuationUpdateDto public string? Remarks { get; set; } public string? LocationLongitude { get; set; } public string? LocationLatitude { get; set; } + public int? LandMiscellaneousMasterFileId { get; set; } } public class LMPastValuationResponseDto @@ -54,5 +56,7 @@ public class LMPastValuationResponseDto public string? Remarks { get; set; } public string? LocationLongitude { get; set; } public string? LocationLatitude { get; set; } + public int? LandMiscellaneousMasterFileId { get; set; } + public LandMiscellaneousMasterFileDto? LandMiscellaneousMasterFile { get; set; } } } diff --git a/Models/DTOs/LMSalesEvidenceDtos.cs b/Models/DTOs/LMSalesEvidenceDtos.cs index a6ea5d6..a0d811e 100644 --- a/Models/DTOs/LMSalesEvidenceDtos.cs +++ b/Models/DTOs/LMSalesEvidenceDtos.cs @@ -26,6 +26,7 @@ public class LMSalesEvidenceCreateDto public string? LandRegistryReferences { get; set; } public string? Situation { get; set; } public string? DescriptionOfProperty { get; set; } + public int? LandMiscellaneousMasterFileId { get; set; } } public class LMSalesEvidenceUpdateDto @@ -54,6 +55,7 @@ public class LMSalesEvidenceUpdateDto public string? LandRegistryReferences { get; set; } public string? Situation { get; set; } public string? DescriptionOfProperty { get; set; } + public int? LandMiscellaneousMasterFileId { get; set; } } public class LMSalesEvidenceResponseDto @@ -81,5 +83,7 @@ public class LMSalesEvidenceResponseDto public string? LandRegistryReferences { get; set; } public string? Situation { get; set; } public string? DescriptionOfProperty { get; set; } + public int? LandMiscellaneousMasterFileId { get; set; } + public LandMiscellaneousMasterFileDto? LandMiscellaneousMasterFile { get; set; } } } diff --git a/Models/LMBuildingRates.cs b/Models/LMBuildingRates.cs index 8af4fff..93061c6 100644 --- a/Models/LMBuildingRates.cs +++ b/Models/LMBuildingRates.cs @@ -31,5 +31,11 @@ public class LMBuildingRates public string? Remarks { get; set; } public string? LocationLatitude { get; set; } public string? LocationLongitude { get; set; } + + // Foreign key to LandMiscellaneousMasterFile table + public int? LandMiscellaneousMasterFileId { get; set; } + + [ForeignKey("LandMiscellaneousMasterFileId")] + public virtual LandMiscellaneousMasterFile? LandMiscellaneousMasterFile { get; set; } } } diff --git a/Models/LMPastValuation.cs b/Models/LMPastValuation.cs index 358e295..16f3e3d 100644 --- a/Models/LMPastValuation.cs +++ b/Models/LMPastValuation.cs @@ -31,5 +31,11 @@ public class LMPastValuation public string? Remarks { get; set; } public string? LocationLongitude { get; set; } public string? LocationLatitude { get; set; } + + // Foreign key to LandMiscellaneousMasterFile table + public int? LandMiscellaneousMasterFileId { get; set; } + + [ForeignKey("LandMiscellaneousMasterFileId")] + public virtual LandMiscellaneousMasterFile? LandMiscellaneousMasterFile { get; set; } } } diff --git a/Models/LMSalesEvidence.cs b/Models/LMSalesEvidence.cs index 303da5d..a25b501 100644 --- a/Models/LMSalesEvidence.cs +++ b/Models/LMSalesEvidence.cs @@ -40,5 +40,11 @@ public class LMSalesEvidence public string? LandRegistryReferences { get; set; } public string? Situation { get; set; } public string? DescriptionOfProperty { get; set; } + + // Foreign key to LandMiscellaneousMasterFile table + public int? LandMiscellaneousMasterFileId { get; set; } + + [ForeignKey("LandMiscellaneousMasterFileId")] + public virtual LandMiscellaneousMasterFile? LandMiscellaneousMasterFile { get; set; } } } diff --git a/repositories/ILMBuildingRatesRepository.cs b/repositories/ILMBuildingRatesRepository.cs index 79e085f..de54e34 100644 --- a/repositories/ILMBuildingRatesRepository.cs +++ b/repositories/ILMBuildingRatesRepository.cs @@ -8,6 +8,8 @@ public interface ILMBuildingRatesRepository { Task> GetAllAsync(); Task GetByIdAsync(int id); + Task GetByIdWithMasterFileAsync(int id); + Task> GetByMasterFileIdAsync(int masterFileId); Task GetByReportIdAsync(int reportId); Task CreateReportAsync(Report report); Task CreateAsync(LMBuildingRates lmBuildingRate); diff --git a/repositories/ILMPastValuationRepository.cs b/repositories/ILMPastValuationRepository.cs index bace7ef..d555f12 100644 --- a/repositories/ILMPastValuationRepository.cs +++ b/repositories/ILMPastValuationRepository.cs @@ -8,6 +8,8 @@ public interface ILMPastValuationRepository { Task> GetAllAsync(); Task GetByIdAsync(int id); + Task GetByIdWithMasterFileAsync(int id); + Task> GetByMasterFileIdAsync(int masterFileId); Task GetByReportIdAsync(int reportId); Task CreateReportAsync(Report report); Task CreateAsync(LMPastValuation lmPastValuation); diff --git a/repositories/ILMSalesEvidenceRepository.cs b/repositories/ILMSalesEvidenceRepository.cs index 40f1854..f5560df 100644 --- a/repositories/ILMSalesEvidenceRepository.cs +++ b/repositories/ILMSalesEvidenceRepository.cs @@ -8,6 +8,8 @@ public interface ILMSalesEvidenceRepository { Task> GetAllAsync(); Task GetByIdAsync(int id); + Task GetByIdWithMasterFileAsync(int id); + Task> GetByMasterFileIdAsync(int masterFileId); Task GetByReportIdAsync(int reportId); Task CreateReportAsync(Report report); Task CreateAsync(LMSalesEvidence lmSalesEvidence); diff --git a/repositories/LMBuildingRatesRepository.cs b/repositories/LMBuildingRatesRepository.cs index 456ba59..d83321a 100644 --- a/repositories/LMBuildingRatesRepository.cs +++ b/repositories/LMBuildingRatesRepository.cs @@ -27,6 +27,21 @@ public async Task GetByIdAsync(int id) return await _context.LMBuildingRates.FindAsync(id); } + public async Task GetByIdWithMasterFileAsync(int id) + { + return await _context.LMBuildingRates + .Include(br => br.LandMiscellaneousMasterFile) + .FirstOrDefaultAsync(br => br.Id == id); + } + + public async Task> GetByMasterFileIdAsync(int masterFileId) + { + return await _context.LMBuildingRates + .Where(br => br.LandMiscellaneousMasterFileId == masterFileId) + .Include(br => br.LandMiscellaneousMasterFile) + .ToListAsync(); + } + public async Task GetByReportIdAsync(int reportId) { return await _context.LMBuildingRates diff --git a/repositories/LMPastValuationRepository.cs b/repositories/LMPastValuationRepository.cs index 472e846..4c35e5e 100644 --- a/repositories/LMPastValuationRepository.cs +++ b/repositories/LMPastValuationRepository.cs @@ -27,6 +27,21 @@ public async Task GetByIdAsync(int id) return await _context.LMPastValuations.FindAsync(id); } + public async Task GetByIdWithMasterFileAsync(int id) + { + return await _context.LMPastValuations + .Include(pv => pv.LandMiscellaneousMasterFile) + .FirstOrDefaultAsync(pv => pv.Id == id); + } + + public async Task> GetByMasterFileIdAsync(int masterFileId) + { + return await _context.LMPastValuations + .Where(pv => pv.LandMiscellaneousMasterFileId == masterFileId) + .Include(pv => pv.LandMiscellaneousMasterFile) + .ToListAsync(); + } + public async Task GetByReportIdAsync(int reportId) { return await _context.LMPastValuations diff --git a/repositories/LMSalesEvidenceRepository.cs b/repositories/LMSalesEvidenceRepository.cs index 285a1a8..a51b62d 100644 --- a/repositories/LMSalesEvidenceRepository.cs +++ b/repositories/LMSalesEvidenceRepository.cs @@ -27,6 +27,21 @@ public async Task GetByIdAsync(int id) return await _context.LMSalesEvidences.FindAsync(id); } + public async Task GetByIdWithMasterFileAsync(int id) + { + return await _context.LMSalesEvidences + .Include(se => se.LandMiscellaneousMasterFile) + .FirstOrDefaultAsync(se => se.Id == id); + } + + public async Task> GetByMasterFileIdAsync(int masterFileId) + { + return await _context.LMSalesEvidences + .Where(se => se.LandMiscellaneousMasterFileId == masterFileId) + .Include(se => se.LandMiscellaneousMasterFile) + .ToListAsync(); + } + public async Task GetByReportIdAsync(int reportId) { return await _context.LMSalesEvidences diff --git a/services/ILMBuildingRatesService.cs b/services/ILMBuildingRatesService.cs index 0f187e5..dfafab5 100644 --- a/services/ILMBuildingRatesService.cs +++ b/services/ILMBuildingRatesService.cs @@ -8,6 +8,7 @@ public interface ILMBuildingRatesService { Task> GetAllAsync(); Task GetByIdAsync(int id); + Task> GetByMasterFileIdAsync(int masterFileId); Task GetByReportIdAsync(int reportId); Task CreateAsync(LMBuildingRatesCreateDto dto); Task UpdateAsync(int reportId, LMBuildingRatesUpdateDto dto); diff --git a/services/ILMPastValuationService.cs b/services/ILMPastValuationService.cs index 048563e..b3b22b5 100644 --- a/services/ILMPastValuationService.cs +++ b/services/ILMPastValuationService.cs @@ -8,6 +8,7 @@ public interface ILMPastValuationService { Task> GetAllAsync(); Task GetByIdAsync(int id); + Task> GetByMasterFileIdAsync(int masterFileId); Task GetByReportIdAsync(int reportId); Task CreateAsync(LMPastValuationCreateDto dto); Task UpdateAsync(int reportId, LMPastValuationUpdateDto dto); diff --git a/services/ILMSalesEvidenceService.cs b/services/ILMSalesEvidenceService.cs index 28b9624..60dae47 100644 --- a/services/ILMSalesEvidenceService.cs +++ b/services/ILMSalesEvidenceService.cs @@ -8,6 +8,7 @@ public interface ILMSalesEvidenceService { Task> GetAllAsync(); Task GetByIdAsync(int id); + Task> GetByMasterFileIdAsync(int masterFileId); Task GetByReportIdAsync(int reportId); Task CreateAsync(LMSalesEvidenceCreateDto dto); Task UpdateAsync(int reportId, LMSalesEvidenceUpdateDto dto); diff --git a/services/LMBuildingRatesService.cs b/services/LMBuildingRatesService.cs index e0fd878..bf017c6 100644 --- a/services/LMBuildingRatesService.cs +++ b/services/LMBuildingRatesService.cs @@ -25,10 +25,16 @@ public async Task> GetAllAsync() public async Task GetByIdAsync(int id) { - var lmBuildingRate = await _repository.GetByIdAsync(id); + var lmBuildingRate = await _repository.GetByIdWithMasterFileAsync(id); return lmBuildingRate == null ? null : MapToResponseDto(lmBuildingRate); } + public async Task> GetByMasterFileIdAsync(int masterFileId) + { + var lmBuildingRates = await _repository.GetByMasterFileIdAsync(masterFileId); + return lmBuildingRates.Select(MapToResponseDto).ToList(); + } + public async Task GetByReportIdAsync(int reportId) { var lmBuildingRate = await _repository.GetByReportIdAsync(reportId); @@ -63,7 +69,8 @@ public async Task CreateAsync(LMBuildingRatesCreateD Cost = dto.Cost, Remarks = dto.Remarks, LocationLatitude = dto.LocationLatitude, - LocationLongitude = dto.LocationLongitude + LocationLongitude = dto.LocationLongitude, + LandMiscellaneousMasterFileId = dto.LandMiscellaneousMasterFileId }; lmBuildingRate = await _repository.CreateAsync(lmBuildingRate); @@ -93,6 +100,7 @@ public async Task UpdateAsync(int reportId, LMBuildingRatesUpdateDto dto) existingLMBuildingRate.Remarks = dto.Remarks; existingLMBuildingRate.LocationLatitude = dto.LocationLatitude; existingLMBuildingRate.LocationLongitude = dto.LocationLongitude; + existingLMBuildingRate.LandMiscellaneousMasterFileId = dto.LandMiscellaneousMasterFileId; return await _repository.UpdateAsync(existingLMBuildingRate); } @@ -119,7 +127,26 @@ private LMBuildingRatesResponseDto MapToResponseDto(LMBuildingRates lmBuildingRa Cost = lmBuildingRate.Cost, Remarks = lmBuildingRate.Remarks, LocationLatitude = lmBuildingRate.LocationLatitude, - LocationLongitude = lmBuildingRate.LocationLongitude + LocationLongitude = lmBuildingRate.LocationLongitude, + LandMiscellaneousMasterFileId = lmBuildingRate.LandMiscellaneousMasterFileId, + LandMiscellaneousMasterFile = lmBuildingRate.LandMiscellaneousMasterFile != null + ? MapMasterFileToDto(lmBuildingRate.LandMiscellaneousMasterFile) + : null + }; + } + + private LandMiscellaneousMasterFileDto MapMasterFileToDto(LandMiscellaneousMasterFile masterFile) + { + return new LandMiscellaneousMasterFileDto + { + Id = masterFile.Id, + MasterFileNo = masterFile.MasterFileNo, + MasterFileRefNo = masterFile.MasterFileRefNo, + PlanType = masterFile.PlanType, + PlanNo = masterFile.PlanNo, + RequestingAuthorityReferenceNo = masterFile.RequestingAuthorityReferenceNo, + Status = masterFile.Status, + Lots = masterFile.Lots }; } } diff --git a/services/LMPastValuationService.cs b/services/LMPastValuationService.cs index df43b9d..152c784 100644 --- a/services/LMPastValuationService.cs +++ b/services/LMPastValuationService.cs @@ -25,10 +25,16 @@ public async Task> GetAllAsync() public async Task GetByIdAsync(int id) { - var lmPastValuation = await _repository.GetByIdAsync(id); + var lmPastValuation = await _repository.GetByIdWithMasterFileAsync(id); return lmPastValuation == null ? null : MapToResponseDto(lmPastValuation); } + public async Task> GetByMasterFileIdAsync(int masterFileId) + { + var lmPastValuations = await _repository.GetByMasterFileIdAsync(masterFileId); + return lmPastValuations.Select(MapToResponseDto).ToList(); + } + public async Task GetByReportIdAsync(int reportId) { var lmPastValuation = await _repository.GetByReportIdAsync(reportId); @@ -63,7 +69,8 @@ public async Task CreateAsync(LMPastValuationCreateD RateType = dto.RateType, Remarks = dto.Remarks, LocationLongitude = dto.LocationLongitude, - LocationLatitude = dto.LocationLatitude + LocationLatitude = dto.LocationLatitude, + LandMiscellaneousMasterFileId = dto.LandMiscellaneousMasterFileId }; lmPastValuation = await _repository.CreateAsync(lmPastValuation); @@ -93,6 +100,7 @@ public async Task UpdateAsync(int reportId, LMPastValuationUpdateDto dto) existingLMPastValuation.Remarks = dto.Remarks; existingLMPastValuation.LocationLongitude = dto.LocationLongitude; existingLMPastValuation.LocationLatitude = dto.LocationLatitude; + existingLMPastValuation.LandMiscellaneousMasterFileId = dto.LandMiscellaneousMasterFileId; return await _repository.UpdateAsync(existingLMPastValuation); } @@ -119,7 +127,26 @@ private LMPastValuationResponseDto MapToResponseDto(LMPastValuation lmPastValuat RateType = lmPastValuation.RateType, Remarks = lmPastValuation.Remarks, LocationLongitude = lmPastValuation.LocationLongitude, - LocationLatitude = lmPastValuation.LocationLatitude + LocationLatitude = lmPastValuation.LocationLatitude, + LandMiscellaneousMasterFileId = lmPastValuation.LandMiscellaneousMasterFileId, + LandMiscellaneousMasterFile = lmPastValuation.LandMiscellaneousMasterFile != null + ? MapMasterFileToDto(lmPastValuation.LandMiscellaneousMasterFile) + : null + }; + } + + private LandMiscellaneousMasterFileDto MapMasterFileToDto(LandMiscellaneousMasterFile masterFile) + { + return new LandMiscellaneousMasterFileDto + { + Id = masterFile.Id, + MasterFileNo = masterFile.MasterFileNo, + MasterFileRefNo = masterFile.MasterFileRefNo, + PlanType = masterFile.PlanType, + PlanNo = masterFile.PlanNo, + RequestingAuthorityReferenceNo = masterFile.RequestingAuthorityReferenceNo, + Status = masterFile.Status, + Lots = masterFile.Lots }; } } diff --git a/services/LMSalesEvidenceService.cs b/services/LMSalesEvidenceService.cs index e528ee9..8c4c491 100644 --- a/services/LMSalesEvidenceService.cs +++ b/services/LMSalesEvidenceService.cs @@ -25,10 +25,16 @@ public async Task> GetAllAsync() public async Task GetByIdAsync(int id) { - var lmSalesEvidence = await _repository.GetByIdAsync(id); + var lmSalesEvidence = await _repository.GetByIdWithMasterFileAsync(id); return lmSalesEvidence == null ? null : MapToResponseDto(lmSalesEvidence); } + public async Task> GetByMasterFileIdAsync(int masterFileId) + { + var lmSalesEvidences = await _repository.GetByMasterFileIdAsync(masterFileId); + return lmSalesEvidences.Select(MapToResponseDto).ToList(); + } + public async Task GetByReportIdAsync(int reportId) { var lmSalesEvidence = await _repository.GetByReportIdAsync(reportId); @@ -72,7 +78,8 @@ public async Task CreateAsync(LMSalesEvidenceCreateD LocationLatitude = dto.LocationLatitude, LandRegistryReferences = dto.LandRegistryReferences, Situation = dto.Situation, - DescriptionOfProperty = dto.DescriptionOfProperty + DescriptionOfProperty = dto.DescriptionOfProperty, + LandMiscellaneousMasterFileId = dto.LandMiscellaneousMasterFileId }; lmSalesEvidence = await _repository.CreateAsync(lmSalesEvidence); @@ -111,6 +118,7 @@ public async Task UpdateAsync(int reportId, LMSalesEvidenceUpdateDto dto) existingLMSalesEvidence.LandRegistryReferences = dto.LandRegistryReferences; existingLMSalesEvidence.Situation = dto.Situation; existingLMSalesEvidence.DescriptionOfProperty = dto.DescriptionOfProperty; + existingLMSalesEvidence.LandMiscellaneousMasterFileId = dto.LandMiscellaneousMasterFileId; return await _repository.UpdateAsync(existingLMSalesEvidence); } @@ -146,7 +154,26 @@ private LMSalesEvidenceResponseDto MapToResponseDto(LMSalesEvidence lmSalesEvide LocationLatitude = lmSalesEvidence.LocationLatitude, LandRegistryReferences = lmSalesEvidence.LandRegistryReferences, Situation = lmSalesEvidence.Situation, - DescriptionOfProperty = lmSalesEvidence.DescriptionOfProperty + DescriptionOfProperty = lmSalesEvidence.DescriptionOfProperty, + LandMiscellaneousMasterFileId = lmSalesEvidence.LandMiscellaneousMasterFileId, + LandMiscellaneousMasterFile = lmSalesEvidence.LandMiscellaneousMasterFile != null + ? MapMasterFileToDto(lmSalesEvidence.LandMiscellaneousMasterFile) + : null + }; + } + + private LandMiscellaneousMasterFileDto MapMasterFileToDto(LandMiscellaneousMasterFile masterFile) + { + return new LandMiscellaneousMasterFileDto + { + Id = masterFile.Id, + MasterFileNo = masterFile.MasterFileNo, + MasterFileRefNo = masterFile.MasterFileRefNo, + PlanType = masterFile.PlanType, + PlanNo = masterFile.PlanNo, + RequestingAuthorityReferenceNo = masterFile.RequestingAuthorityReferenceNo, + Status = masterFile.Status, + Lots = masterFile.Lots }; } }