diff --git a/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/UserLogic.cs b/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/UserLogic.cs index 0802e67..bce5692 100644 --- a/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/UserLogic.cs +++ b/CaseAccounting/CaseAccountingBusinessLogics/BusinessLogics/UserLogic.cs @@ -97,11 +97,6 @@ namespace CaseAccountingBusinessLogic.BusinessLogics { return; } - if (model.RoleId < 0) - { - throw new ArgumentNullException("Некорректный идентификатор роли", - nameof(model.RoleId)); - } if (model.Login == string.Empty) { throw new ArgumentNullException("Некорректный ввод логина", diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517211913_Sec.Designer.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517211913_Sec.Designer.cs new file mode 100644 index 0000000..8aab2fa --- /dev/null +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517211913_Sec.Designer.cs @@ -0,0 +1,553 @@ +// +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("20230517211913_Sec")] + partial class Sec + { + /// + 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.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("Role") + .HasColumnType("integer"); + + b.HasKey("Id"); + + 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.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.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/20230517211913_Sec.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517211913_Sec.cs new file mode 100644 index 0000000..6e3b85e --- /dev/null +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230517211913_Sec.cs @@ -0,0 +1,66 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace CaseAccountingDataBaseImplement.Migrations +{ + /// + public partial class Sec : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Users_Roles_RoleId", + table: "Users"); + + migrationBuilder.DropTable( + name: "Roles"); + + migrationBuilder.DropIndex( + name: "IX_Users_RoleId", + table: "Users"); + + migrationBuilder.RenameColumn( + name: "RoleId", + table: "Users", + newName: "Role"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Role", + table: "Users", + newName: "RoleId"); + + 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.CreateIndex( + name: "IX_Users_RoleId", + table: "Users", + column: "RoleId"); + + migrationBuilder.AddForeignKey( + name: "FK_Users_Roles_RoleId", + table: "Users", + column: "RoleId", + principalTable: "Roles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/CaseAccountingDatabaseModelSnapshot.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/CaseAccountingDatabaseModelSnapshot.cs index 377a492..6723299 100644 --- a/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/CaseAccountingDatabaseModelSnapshot.cs +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Migrations/CaseAccountingDatabaseModelSnapshot.cs @@ -281,23 +281,6 @@ namespace CaseAccountingDataBaseImplement.Migrations 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") @@ -336,13 +319,11 @@ namespace CaseAccountingDataBaseImplement.Migrations .IsRequired() .HasColumnType("text"); - b.Property("RoleId") + b.Property("Role") .HasColumnType("integer"); b.HasKey("Id"); - b.HasIndex("RoleId"); - b.ToTable("Users"); }); @@ -512,17 +493,6 @@ namespace CaseAccountingDataBaseImplement.Migrations 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"); @@ -553,11 +523,6 @@ namespace CaseAccountingDataBaseImplement.Migrations b.Navigation("LawyerContracts"); }); - modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Role", b => - { - b.Navigation("Users"); - }); - modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b => { b.Navigation("Cases"); diff --git a/CaseAccounting/CaseAccountingRestApi/Controllers/CaseController.cs b/CaseAccounting/CaseAccountingRestApi/Controllers/CaseController.cs index 1802b22..28516e6 100644 --- a/CaseAccounting/CaseAccountingRestApi/Controllers/CaseController.cs +++ b/CaseAccounting/CaseAccountingRestApi/Controllers/CaseController.cs @@ -43,32 +43,6 @@ namespace CaseAccountingRestApi.Controllers } } - /*[HttpGet] - public List? GetMany(int userId, int page) - { - try - { - return _logic.ReadList(new CaseSearchModel { UserId = userId, PageNumber = page, PageSize = 10 }); - } - catch (Exception) - { - throw; - } - }*/ - - /*[HttpGet] - public int GetNumberOfPages(int userId) - { - try - { - return _studentLogic.GetNumberOfPages(userId); - } - catch (Exception ex) - { - throw; - } - }*/ - [HttpPost] public void Create(CaseBindingModel model) {