From d4044aa7b3260f08ec6799f25c6f31f18a81c5f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Thu, 29 May 2025 11:41:36 +0200 Subject: [PATCH] Add IsCancelled to Layer model --- .../CreateDataInboxImportWorker .sql | 4 +- .../Admin-Monthly/CreateImportWorker.sql | 4 +- ...eProcessWorker-T3MultiSourceSummary-AA.sql | 4 +- .../CreateProcessWorker-T3SingleSource.sql | 4 +- .../CreateProcessWorker-T4SingleSource.sql | 4 +- .../CreateProcessWorker-T5LastValue.sql | 4 +- ...250529093632_LayersIsCancelled.Designer.cs | 384 ++++++++++++++++++ .../20250529093632_LayersIsCancelled.cs | 29 ++ .../Migrations/AppDbContextModelSnapshot.cs | 3 + WebAPI/Models/Layer.cs | 4 +- 10 files changed, 431 insertions(+), 13 deletions(-) create mode 100644 WebAPI/Migrations/20250529093632_LayersIsCancelled.Designer.cs create mode 100644 WebAPI/Migrations/20250529093632_LayersIsCancelled.cs diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateDataInboxImportWorker .sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateDataInboxImportWorker .sql index 211b027..23e3fa9 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateDataInboxImportWorker .sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateDataInboxImportWorker .sql @@ -34,8 +34,8 @@ END; INSERT INTO [diunabi-morska].[dbo].[Layers] -([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type]) -VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); +([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [IsCancelled], [CreatedById], [ModifiedById], [Type]) +VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorker.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorker.sql index e71f909..b9a276a 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorker.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorker.sql @@ -62,8 +62,8 @@ END; INSERT INTO [diunabi-morska].[dbo].[Layers] -([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type]) -VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); +([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [IsCancelled], [CreatedById], [ModifiedById], [Type]) +VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3MultiSourceSummary-AA.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3MultiSourceSummary-AA.sql index 372ee14..e20657f 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3MultiSourceSummary-AA.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3MultiSourceSummary-AA.sql @@ -22,8 +22,8 @@ BEGIN END; INSERT INTO [diunabi-morska].[dbo].[Layers] -([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted],[CreatedById], [ModifiedById], [Type]) -VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); +([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [IsCancelled], [CreatedById], [ModifiedById], [Type]) +VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3SingleSource.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3SingleSource.sql index a009a0d..9e3ad36 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3SingleSource.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3SingleSource.sql @@ -38,8 +38,8 @@ END; INSERT INTO [diunabi-morska].[dbo].[Layers] -([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type]) -VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); +([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [IsCancelled], [CreatedById], [ModifiedById], [Type]) +VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T4SingleSource.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T4SingleSource.sql index b1c7c9f..dbe2e3c 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T4SingleSource.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T4SingleSource.sql @@ -31,9 +31,9 @@ BEGIN END; INSERT INTO [diunabi-morska].[dbo].[Layers] -([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], +([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [IsCancelled], [CreatedById], [ModifiedById], [Type]) -VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); +VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T5LastValue.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T5LastValue.sql index 74ddcd9..2ee8fa3 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T5LastValue.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T5LastValue.sql @@ -30,9 +30,9 @@ END; INSERT INTO [diunabi-morska].[dbo].[Layers] -([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], +([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [IsCancelled], [CreatedById], [ModifiedById], [Type]) -VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); +VALUES (@LayerId, @Number, @Name, GETDATE(), GETDATE(), 0, 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) diff --git a/WebAPI/Migrations/20250529093632_LayersIsCancelled.Designer.cs b/WebAPI/Migrations/20250529093632_LayersIsCancelled.Designer.cs new file mode 100644 index 0000000..1958056 --- /dev/null +++ b/WebAPI/Migrations/20250529093632_LayersIsCancelled.Designer.cs @@ -0,0 +1,384 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebAPI; + +#nullable disable + +namespace WebAPI.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20250529093632_LayersIsCancelled")] + partial class LayersIsCancelled + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.DataInbox", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .IsRequired() + .HasMaxLength(2147483647) + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("DataInbox"); + }); + + modelBuilder.Entity("WebAPI.Models.Layer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("IsCancelled") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Number") + .HasColumnType("int"); + + b.Property("ParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("ModifiedById"); + + b.HasIndex("ParentId"); + + b.ToTable("Layers"); + }); + + modelBuilder.Entity("WebAPI.Models.ProcessSource", b => + { + b.Property("LayerId") + .HasColumnType("uniqueidentifier"); + + b.Property("SourceId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("LayerId", "SourceId"); + + b.HasIndex("SourceId"); + + b.ToTable("ProcessSources"); + }); + + modelBuilder.Entity("WebAPI.Models.QueueJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Attempts") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("LayerId") + .HasColumnType("uniqueidentifier"); + + b.Property("Message") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("QueueJobs"); + }); + + modelBuilder.Entity("WebAPI.Models.Record", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Desc1") + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LayerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Value1") + .HasColumnType("float"); + + b.Property("Value10") + .HasColumnType("float"); + + b.Property("Value11") + .HasColumnType("float"); + + b.Property("Value12") + .HasColumnType("float"); + + b.Property("Value13") + .HasColumnType("float"); + + b.Property("Value14") + .HasColumnType("float"); + + b.Property("Value15") + .HasColumnType("float"); + + b.Property("Value16") + .HasColumnType("float"); + + b.Property("Value17") + .HasColumnType("float"); + + b.Property("Value18") + .HasColumnType("float"); + + b.Property("Value19") + .HasColumnType("float"); + + b.Property("Value2") + .HasColumnType("float"); + + b.Property("Value20") + .HasColumnType("float"); + + b.Property("Value21") + .HasColumnType("float"); + + b.Property("Value22") + .HasColumnType("float"); + + b.Property("Value23") + .HasColumnType("float"); + + b.Property("Value24") + .HasColumnType("float"); + + b.Property("Value25") + .HasColumnType("float"); + + b.Property("Value26") + .HasColumnType("float"); + + b.Property("Value27") + .HasColumnType("float"); + + b.Property("Value28") + .HasColumnType("float"); + + b.Property("Value29") + .HasColumnType("float"); + + b.Property("Value3") + .HasColumnType("float"); + + b.Property("Value30") + .HasColumnType("float"); + + b.Property("Value31") + .HasColumnType("float"); + + b.Property("Value32") + .HasColumnType("float"); + + b.Property("Value4") + .HasColumnType("float"); + + b.Property("Value5") + .HasColumnType("float"); + + b.Property("Value6") + .HasColumnType("float"); + + b.Property("Value7") + .HasColumnType("float"); + + b.Property("Value8") + .HasColumnType("float"); + + b.Property("Value9") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("LayerId"); + + b.HasIndex("ModifiedById"); + + b.ToTable("Records"); + }); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("WebAPI.Models.Layer", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.Layer", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("WebAPI.Models.ProcessSource", b => + { + b.HasOne("WebAPI.Models.Layer", "Source") + .WithMany() + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("WebAPI.Models.Record", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.Layer", null) + .WithMany("Records") + .HasForeignKey("LayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.Layer", b => + { + b.Navigation("Records"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebAPI/Migrations/20250529093632_LayersIsCancelled.cs b/WebAPI/Migrations/20250529093632_LayersIsCancelled.cs new file mode 100644 index 0000000..bd0ceaa --- /dev/null +++ b/WebAPI/Migrations/20250529093632_LayersIsCancelled.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebAPI.Migrations +{ + /// + public partial class LayersIsCancelled : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsCancelled", + table: "Layers", + type: "bit", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsCancelled", + table: "Layers"); + } + } +} diff --git a/WebAPI/Migrations/AppDbContextModelSnapshot.cs b/WebAPI/Migrations/AppDbContextModelSnapshot.cs index 0bc7a69..f9691c9 100644 --- a/WebAPI/Migrations/AppDbContextModelSnapshot.cs +++ b/WebAPI/Migrations/AppDbContextModelSnapshot.cs @@ -63,6 +63,9 @@ namespace WebAPI.Migrations b.Property("CreatedById") .HasColumnType("uniqueidentifier"); + b.Property("IsCancelled") + .HasColumnType("bit"); + b.Property("IsDeleted") .HasColumnType("bit"); diff --git a/WebAPI/Models/Layer.cs b/WebAPI/Models/Layer.cs index 0de22f4..0cfd9ba 100644 --- a/WebAPI/Models/Layer.cs +++ b/WebAPI/Models/Layer.cs @@ -26,7 +26,9 @@ public class Layer [Required] public DateTime ModifiedAt { get; set; } [Required] - public bool IsDeleted { get; init; } + public bool IsDeleted { get; init; } = false; + [Required] + public bool IsCancelled { get; init; } = false; #endregion #region Relations public ICollection? Records { get; init; }