remove Version property from Law model and related classes - Add migration
This commit is contained in:
@@ -7,22 +7,19 @@ namespace Company.Domain.LawAgg
|
||||
public class Law : EntityBase
|
||||
{
|
||||
public string Title { get; private set; }
|
||||
public int Version { get; private set; }
|
||||
public bool IsActive { get; private set; }
|
||||
public List<LawItem> Items { get; private set; }
|
||||
|
||||
public Law(string title, int version)
|
||||
public Law(string title)
|
||||
{
|
||||
Title = title;
|
||||
Version = version;
|
||||
IsActive = false;
|
||||
Items = new List<LawItem>();
|
||||
}
|
||||
|
||||
public void Edit(string title, int version)
|
||||
public void Edit(string title)
|
||||
{
|
||||
Title = title;
|
||||
Version = version;
|
||||
}
|
||||
|
||||
public void AddItem(string header, string details, int orderNumber)
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace CompanyManagment.App.Contracts.Law
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public int Version { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public List<LawItemViewModel> Items { get; set; }
|
||||
@@ -23,7 +22,6 @@ namespace CompanyManagment.App.Contracts.Law
|
||||
public class CreateLaw
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public int Version { get; set; }
|
||||
public List<LawItemViewModel> Items { get; set; }
|
||||
}
|
||||
|
||||
@@ -31,6 +29,5 @@ namespace CompanyManagment.App.Contracts.Law
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public int Version { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
|
||||
var law = new Law(command.Title, command.Version);
|
||||
var law = new Law(command.Title);
|
||||
|
||||
if (command.Items != null && command.Items.Any())
|
||||
{
|
||||
@@ -43,7 +43,7 @@ namespace CompanyManagment.Application
|
||||
if (law == null)
|
||||
return operation.Failed(ApplicationMessages.RecordNotFound);
|
||||
|
||||
law.Edit(command.Title, command.Version);
|
||||
law.Edit(command.Title);
|
||||
|
||||
_lawRepository.SaveChanges();
|
||||
return operation.Succcedded();
|
||||
@@ -82,7 +82,6 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
Id = law.id,
|
||||
Title = law.Title,
|
||||
Version = law.Version
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,7 +92,6 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
Id = x.id,
|
||||
Title = x.Title,
|
||||
Version = x.Version,
|
||||
IsActive = x.IsActive,
|
||||
CreatedAt = x.CreationDate
|
||||
}).ToList();
|
||||
@@ -106,7 +104,6 @@ namespace CompanyManagment.Application
|
||||
{
|
||||
Id = law.id,
|
||||
Title = law.Title,
|
||||
Version = law.Version,
|
||||
IsActive = law.IsActive,
|
||||
CreatedAt = law.CreationDate,
|
||||
Items = law.Items.Select(x => new LawItemViewModel
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace CompanyManagment.EFCore.Mapping
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.Title).HasMaxLength(255).IsRequired();
|
||||
builder.Property(x => x.Version).IsRequired();
|
||||
builder.Property(x => x.IsActive).IsRequired();
|
||||
|
||||
builder.OwnsMany(x => x.Items, navigationBuilder =>
|
||||
|
||||
10323
CompanyManagment.EFCore/Migrations/20250816094851_Add law table.Designer.cs
generated
Normal file
10323
CompanyManagment.EFCore/Migrations/20250816094851_Add law table.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Addlawtable : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Law",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Title = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Law", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LawItem",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Header = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true),
|
||||
Details = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
OrderNumber = table.Column<int>(type: "int", nullable: false),
|
||||
LawId = table.Column<long>(type: "bigint", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LawItem", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_LawItem_Law_LawId",
|
||||
column: x => x.LawId,
|
||||
principalTable: "Law",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LawItem_LawId",
|
||||
table: "LawItem",
|
||||
column: "LawId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "LawItem");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Law");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3679,6 +3679,30 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.ToTable("Jobs", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.LawAgg.Law", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("nvarchar(255)");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("Law", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.LeaveAgg.Leave", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
@@ -9495,6 +9519,43 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Navigation("Workshop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.LawAgg.Law", b =>
|
||||
{
|
||||
b.OwnsMany("Company.Domain.LawAgg.LawItem", "Items", b1 =>
|
||||
{
|
||||
b1.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property<long>("Id"));
|
||||
|
||||
b1.Property<string>("Details")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b1.Property<string>("Header")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("nvarchar(255)");
|
||||
|
||||
b1.Property<long>("LawId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<int>("OrderNumber")
|
||||
.HasColumnType("int");
|
||||
|
||||
b1.HasKey("Id");
|
||||
|
||||
b1.HasIndex("LawId");
|
||||
|
||||
b1.ToTable("LawItem", (string)null);
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("LawId");
|
||||
});
|
||||
|
||||
b.Navigation("Items");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.LeftWorkAgg.LeftWork", b =>
|
||||
{
|
||||
b.HasOne("Company.Domain.EmployeeAgg.Employee", "Employee")
|
||||
|
||||
Reference in New Issue
Block a user