diff --git a/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/UserLogic.cs b/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/UserLogic.cs index 0159efc..0802e67 100644 --- a/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/UserLogic.cs +++ b/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/UserLogic.cs @@ -17,7 +17,7 @@ namespace CaseAccountingBusinessLogic.BusinessLogics private readonly ILogger _logger; private readonly IUserStorage _userStorage; - public UserLogic(ILogger logger, IUserStorage userStorage) + public UserLogic(ILogger logger, IUserStorage userStorage) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _userStorage = userStorage ?? throw new ArgumentNullException(nameof(userStorage)); diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDataBaseImplement.csproj b/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDataBaseImplement.csproj index 128e65c..f12573e 100644 --- a/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDataBaseImplement.csproj +++ b/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDataBaseImplement.csproj @@ -7,8 +7,12 @@ - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDatabase.cs b/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDatabase.cs index 3958d65..8b1f8f0 100644 --- a/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDatabase.cs +++ b/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDatabase.cs @@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement Host=localhost; Port=5432; Database=CaseAccountingDatabase; - Username=postgres; - Password=postgres"); + Username=courseuser; + Password=courseuser"); } base.OnConfiguring(optionsBuilder); } diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517203108_Init.Designer.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517203108_Init.Designer.cs new file mode 100644 index 0000000..8ca1533 --- /dev/null +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517203108_Init.Designer.cs @@ -0,0 +1,588 @@ +// +using System; +using CaseAccountingDataBaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace CaseAccountingDataBaseImplement.Migrations +{ + [DbContext(typeof(CaseAccountingDatabase))] + [Migration("20230517203108_Init")] + partial class Init + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Annotation") + .IsRequired() + .HasColumnType("text"); + + b.Property("Applicant") + .IsRequired() + .HasColumnType("text"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Defendant") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SpecializationId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SpecializationId"); + + b.HasIndex("UserId"); + + b.ToTable("Cases"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CaseId") + .HasColumnType("integer"); + + b.Property("DealId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CaseId"); + + b.HasIndex("DealId"); + + b.ToTable("CaseDeals"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CaseId") + .HasColumnType("integer"); + + b.Property("LawyerId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CaseId"); + + b.HasIndex("LawyerId"); + + b.ToTable("CaseLawyers"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Coast") + .HasColumnType("numeric"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Service") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Contracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Responsibilities") + .IsRequired() + .HasColumnType("text"); + + b.Property("Subject") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Deals"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("DealId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("DealId"); + + b.ToTable("DealContracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CaseId") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Information") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CaseId"); + + b.HasIndex("UserId"); + + b.ToTable("Hearings"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Experience") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Patronymic") + .IsRequired() + .HasColumnType("text"); + + b.Property("SpecializationId") + .HasColumnType("integer"); + + b.Property("Surname") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SpecializationId"); + + b.HasIndex("UserId"); + + b.ToTable("Lawyers"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("LawyerId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("LawyerId"); + + b.ToTable("LawyerContracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Specializations"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Login") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization") + .WithMany("Cases") + .HasForeignKey("SpecializationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Cases") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Specialization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case") + .WithMany("Deals") + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal") + .WithMany("CaseDeals") + .HasForeignKey("DealId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + + b.Navigation("Deal"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case") + .WithMany("CaseLawyers") + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer") + .WithMany("CaseLawyers") + .HasForeignKey("LawyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + + b.Navigation("Lawyer"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Contracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Deals") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract") + .WithMany("DealContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal") + .WithMany("Contracts") + .HasForeignKey("DealId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("Deal"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case") + .WithMany("Hearings") + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Hearings") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization") + .WithMany("Lawyers") + .HasForeignKey("SpecializationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Lawyers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Specialization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract") + .WithMany("LawyerContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer") + .WithMany("LawyerContracts") + .HasForeignKey("LawyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("Lawyer"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Specializations") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Role", "Role") + .WithMany("Users") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b => + { + b.Navigation("CaseLawyers"); + + b.Navigation("Deals"); + + b.Navigation("Hearings"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b => + { + b.Navigation("DealContracts"); + + b.Navigation("LawyerContracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b => + { + b.Navigation("CaseDeals"); + + b.Navigation("Contracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b => + { + b.Navigation("CaseLawyers"); + + b.Navigation("LawyerContracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Role", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b => + { + b.Navigation("Cases"); + + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b => + { + b.Navigation("Cases"); + + b.Navigation("Contracts"); + + b.Navigation("Deals"); + + b.Navigation("Hearings"); + + b.Navigation("Lawyers"); + + b.Navigation("Specializations"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517203108_Init.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517203108_Init.cs new file mode 100644 index 0000000..2cfebd6 --- /dev/null +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517203108_Init.cs @@ -0,0 +1,437 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace CaseAccountingDataBaseImplement.Migrations +{ + /// + public partial class Init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Roles", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Roles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Login = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false), + RoleId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + table.ForeignKey( + name: "FK_Users_Roles_RoleId", + column: x => x.RoleId, + principalTable: "Roles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Contracts", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Service = table.Column(type: "text", nullable: false), + Coast = table.Column(type: "numeric", nullable: false), + Date = table.Column(type: "timestamp with time zone", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Contracts", x => x.Id); + table.ForeignKey( + name: "FK_Contracts_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Deals", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Subject = table.Column(type: "text", nullable: false), + Responsibilities = table.Column(type: "text", nullable: false), + Date = table.Column(type: "timestamp with time zone", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Deals", x => x.Id); + table.ForeignKey( + name: "FK_Deals_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Specializations", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Specializations", x => x.Id); + table.ForeignKey( + name: "FK_Specializations_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "DealContracts", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DealId = table.Column(type: "integer", nullable: false), + ContractId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DealContracts", x => x.Id); + table.ForeignKey( + name: "FK_DealContracts_Contracts_ContractId", + column: x => x.ContractId, + principalTable: "Contracts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_DealContracts_Deals_DealId", + column: x => x.DealId, + principalTable: "Deals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Cases", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Applicant = table.Column(type: "text", nullable: false), + Defendant = table.Column(type: "text", nullable: false), + Annotation = table.Column(type: "text", nullable: false), + Date = table.Column(type: "timestamp with time zone", nullable: false), + SpecializationId = table.Column(type: "integer", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Cases", x => x.Id); + table.ForeignKey( + name: "FK_Cases_Specializations_SpecializationId", + column: x => x.SpecializationId, + principalTable: "Specializations", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Cases_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Lawyers", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Surname = table.Column(type: "text", nullable: false), + Patronymic = table.Column(type: "text", nullable: false), + Experience = table.Column(type: "integer", nullable: false), + SpecializationId = table.Column(type: "integer", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Lawyers", x => x.Id); + table.ForeignKey( + name: "FK_Lawyers_Specializations_SpecializationId", + column: x => x.SpecializationId, + principalTable: "Specializations", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Lawyers_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CaseDeals", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CaseId = table.Column(type: "integer", nullable: false), + DealId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CaseDeals", x => x.Id); + table.ForeignKey( + name: "FK_CaseDeals_Cases_CaseId", + column: x => x.CaseId, + principalTable: "Cases", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CaseDeals_Deals_DealId", + column: x => x.DealId, + principalTable: "Deals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Hearings", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Information = table.Column(type: "text", nullable: false), + Date = table.Column(type: "timestamp with time zone", nullable: false), + CaseId = table.Column(type: "integer", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Hearings", x => x.Id); + table.ForeignKey( + name: "FK_Hearings_Cases_CaseId", + column: x => x.CaseId, + principalTable: "Cases", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Hearings_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CaseLawyers", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CaseId = table.Column(type: "integer", nullable: false), + LawyerId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CaseLawyers", x => x.Id); + table.ForeignKey( + name: "FK_CaseLawyers_Cases_CaseId", + column: x => x.CaseId, + principalTable: "Cases", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CaseLawyers_Lawyers_LawyerId", + column: x => x.LawyerId, + principalTable: "Lawyers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "LawyerContracts", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + LawyerId = table.Column(type: "integer", nullable: false), + ContractId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_LawyerContracts", x => x.Id); + table.ForeignKey( + name: "FK_LawyerContracts_Contracts_ContractId", + column: x => x.ContractId, + principalTable: "Contracts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_LawyerContracts_Lawyers_LawyerId", + column: x => x.LawyerId, + principalTable: "Lawyers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_CaseDeals_CaseId", + table: "CaseDeals", + column: "CaseId"); + + migrationBuilder.CreateIndex( + name: "IX_CaseDeals_DealId", + table: "CaseDeals", + column: "DealId"); + + migrationBuilder.CreateIndex( + name: "IX_CaseLawyers_CaseId", + table: "CaseLawyers", + column: "CaseId"); + + migrationBuilder.CreateIndex( + name: "IX_CaseLawyers_LawyerId", + table: "CaseLawyers", + column: "LawyerId"); + + migrationBuilder.CreateIndex( + name: "IX_Cases_SpecializationId", + table: "Cases", + column: "SpecializationId"); + + migrationBuilder.CreateIndex( + name: "IX_Cases_UserId", + table: "Cases", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Contracts_UserId", + table: "Contracts", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_DealContracts_ContractId", + table: "DealContracts", + column: "ContractId"); + + migrationBuilder.CreateIndex( + name: "IX_DealContracts_DealId", + table: "DealContracts", + column: "DealId"); + + migrationBuilder.CreateIndex( + name: "IX_Deals_UserId", + table: "Deals", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Hearings_CaseId", + table: "Hearings", + column: "CaseId"); + + migrationBuilder.CreateIndex( + name: "IX_Hearings_UserId", + table: "Hearings", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_LawyerContracts_ContractId", + table: "LawyerContracts", + column: "ContractId"); + + migrationBuilder.CreateIndex( + name: "IX_LawyerContracts_LawyerId", + table: "LawyerContracts", + column: "LawyerId"); + + migrationBuilder.CreateIndex( + name: "IX_Lawyers_SpecializationId", + table: "Lawyers", + column: "SpecializationId"); + + migrationBuilder.CreateIndex( + name: "IX_Lawyers_UserId", + table: "Lawyers", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Specializations_UserId", + table: "Specializations", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_RoleId", + table: "Users", + column: "RoleId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CaseDeals"); + + migrationBuilder.DropTable( + name: "CaseLawyers"); + + migrationBuilder.DropTable( + name: "DealContracts"); + + migrationBuilder.DropTable( + name: "Hearings"); + + migrationBuilder.DropTable( + name: "LawyerContracts"); + + migrationBuilder.DropTable( + name: "Deals"); + + migrationBuilder.DropTable( + name: "Cases"); + + migrationBuilder.DropTable( + name: "Contracts"); + + migrationBuilder.DropTable( + name: "Lawyers"); + + migrationBuilder.DropTable( + name: "Specializations"); + + migrationBuilder.DropTable( + name: "Users"); + + migrationBuilder.DropTable( + name: "Roles"); + } + } +} diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/CaseAccountingDatabaseModelSnapshot.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/CaseAccountingDatabaseModelSnapshot.cs new file mode 100644 index 0000000..377a492 --- /dev/null +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/CaseAccountingDatabaseModelSnapshot.cs @@ -0,0 +1,585 @@ +// +using System; +using CaseAccountingDataBaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace CaseAccountingDataBaseImplement.Migrations +{ + [DbContext(typeof(CaseAccountingDatabase))] + partial class CaseAccountingDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Annotation") + .IsRequired() + .HasColumnType("text"); + + b.Property("Applicant") + .IsRequired() + .HasColumnType("text"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Defendant") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SpecializationId") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SpecializationId"); + + b.HasIndex("UserId"); + + b.ToTable("Cases"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CaseId") + .HasColumnType("integer"); + + b.Property("DealId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CaseId"); + + b.HasIndex("DealId"); + + b.ToTable("CaseDeals"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CaseId") + .HasColumnType("integer"); + + b.Property("LawyerId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CaseId"); + + b.HasIndex("LawyerId"); + + b.ToTable("CaseLawyers"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Coast") + .HasColumnType("numeric"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Service") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Contracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Responsibilities") + .IsRequired() + .HasColumnType("text"); + + b.Property("Subject") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Deals"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("DealId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("DealId"); + + b.ToTable("DealContracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CaseId") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Information") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CaseId"); + + b.HasIndex("UserId"); + + b.ToTable("Hearings"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Experience") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Patronymic") + .IsRequired() + .HasColumnType("text"); + + b.Property("SpecializationId") + .HasColumnType("integer"); + + b.Property("Surname") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SpecializationId"); + + b.HasIndex("UserId"); + + b.ToTable("Lawyers"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("LawyerId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("LawyerId"); + + b.ToTable("LawyerContracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Specializations"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Login") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization") + .WithMany("Cases") + .HasForeignKey("SpecializationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Cases") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Specialization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case") + .WithMany("Deals") + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal") + .WithMany("CaseDeals") + .HasForeignKey("DealId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + + b.Navigation("Deal"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case") + .WithMany("CaseLawyers") + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer") + .WithMany("CaseLawyers") + .HasForeignKey("LawyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + + b.Navigation("Lawyer"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Contracts") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Deals") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract") + .WithMany("DealContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal") + .WithMany("Contracts") + .HasForeignKey("DealId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("Deal"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case") + .WithMany("Hearings") + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Hearings") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization") + .WithMany("Lawyers") + .HasForeignKey("SpecializationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Lawyers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Specialization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract") + .WithMany("LawyerContracts") + .HasForeignKey("ContractId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer") + .WithMany("LawyerContracts") + .HasForeignKey("LawyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contract"); + + b.Navigation("Lawyer"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") + .WithMany("Specializations") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b => + { + b.HasOne("CaseAccountingDataBaseImplement.Models.Role", "Role") + .WithMany("Users") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b => + { + b.Navigation("CaseLawyers"); + + b.Navigation("Deals"); + + b.Navigation("Hearings"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b => + { + b.Navigation("DealContracts"); + + b.Navigation("LawyerContracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b => + { + b.Navigation("CaseDeals"); + + b.Navigation("Contracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b => + { + b.Navigation("CaseLawyers"); + + b.Navigation("LawyerContracts"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Role", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b => + { + b.Navigation("Cases"); + + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b => + { + b.Navigation("Cases"); + + b.Navigation("Contracts"); + + b.Navigation("Deals"); + + b.Navigation("Hearings"); + + b.Navigation("Lawyers"); + + b.Navigation("Specializations"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CaseAccounting/CaseAccountingRestApi/CaseAccountingRestApi.csproj b/CaseAccounting/CaseAccountingRestApi/CaseAccountingRestApi.csproj index de3712e..a925a15 100644 --- a/CaseAccounting/CaseAccountingRestApi/CaseAccountingRestApi.csproj +++ b/CaseAccounting/CaseAccountingRestApi/CaseAccountingRestApi.csproj @@ -7,6 +7,11 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/CaseAccounting/CaseAccountingRestApi/Controllers/HearingController.cs b/CaseAccounting/CaseAccountingRestApi/Controllers/HearingController.cs new file mode 100644 index 0000000..6d5391d --- /dev/null +++ b/CaseAccounting/CaseAccountingRestApi/Controllers/HearingController.cs @@ -0,0 +1,85 @@ +using CaseAccountingContracts.BindingModels; +using CaseAccountingContracts.BusinessLogicContracts; +using CaseAccountingContracts.SearchModels; +using CaseAccountingContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace CaseAccountingRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class HearingController : Controller + { + private readonly IHearingLogic _logic; + + public HearingController(IHearingLogic logic) + { + _logic = logic; + } + + [HttpGet] + public HearingViewModel? Get(int id) + { + try + { + return _logic.ReadElement(new HearingSearchModel { Id = id }); + } + catch (Exception) + { + throw; + } + } + + [HttpGet] + public List? GetAllByUser(int userId) + { + try + { + return _logic.ReadList(null); + } + catch (Exception) + { + throw; + } + } + + [HttpPost] + public void Create(HearingBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception) + { + throw; + } + } + + [HttpPost] + public void Update(HearingBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception) + { + throw; + } + } + + [HttpPost] + public void Delete(HearingBindingModel model) + { + try + { + _logic.Delete(new() { Id = model.Id }); + } + catch (Exception) + { + throw; + } + } + } +} diff --git a/CaseAccounting/CaseAccountingRestApi/Program.cs b/CaseAccounting/CaseAccountingRestApi/Program.cs index 308b4d2..e0098d2 100644 --- a/CaseAccounting/CaseAccountingRestApi/Program.cs +++ b/CaseAccounting/CaseAccountingRestApi/Program.cs @@ -6,8 +6,8 @@ using Microsoft.OpenApi.Models; var builder = WebApplication.CreateBuilder(args); -//builder.Logging.SetMinimumLevel(LogLevel.Trace); -//builder.Logging.AddLog4Net("log4net.config"); +builder.Logging.SetMinimumLevel(LogLevel.Trace); +builder.Logging.AddLog4Net("log4net.config"); // Add services to the container. builder.Services.AddTransient();