Merge branch 'main' into HelpBench

This commit is contained in:
Артём Алейкин 2023-05-18 16:54:30 +04:00
commit 5e5fdc43f3
20 changed files with 646 additions and 190 deletions

View File

@ -97,11 +97,6 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
{ {
return; return;
} }
if (model.RoleId < 0)
{
throw new ArgumentNullException("Некорректный идентификатор роли",
nameof(model.RoleId));
}
if (model.Login == string.Empty) if (model.Login == string.Empty)
{ {
throw new ArgumentNullException("Некорректный ввод логина", throw new ArgumentNullException("Некорректный ввод логина",

View File

@ -1,16 +0,0 @@
using CaseAccountingDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingContracts.BindingModels
{
public class RoleBindingModel : IRoleModel
{
public string Name { get; set; } = string.Empty;
public int Id { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using CaseAccountingDataModels.Models; using CaseAccountingDataModels.Enum;
using CaseAccountingDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -13,7 +14,7 @@ namespace CaseAccountingContracts.BindingModels
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
public int RoleId { get; set; } public Role Role { get; set; }
public int Id { get; set; } public int Id { get; set; }
} }

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingContracts.SearchModels
{
public class RoleSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using System; using CaseAccountingDataModels.Enum;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -14,6 +15,6 @@ namespace CaseAccountingContracts.SearchModels
public string? Password { get; set; } public string? Password { get; set; }
public int? RoleId { get; set; } public Role? Role { get; set; }
} }
} }

View File

@ -1,18 +0,0 @@
using CaseAccountingDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingContracts.ViewModels
{
public class RoleViewModel : IRoleModel
{
public int Id { get; set; }
[DisplayName("Название роли")]
public string Name { get; set; } = string.Empty;
}
}

View File

@ -1,4 +1,5 @@
using CaseAccountingDataModels.Models; using CaseAccountingDataModels.Enum;
using CaseAccountingDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -16,6 +17,6 @@ namespace CaseAccountingContracts.ViewModels
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
public int RoleId { get; set; } public Role Role { get; set; }
} }
} }

View File

@ -28,8 +28,6 @@ namespace CaseAccountingDataBaseImplement
public virtual DbSet<User> Users { set; get; } public virtual DbSet<User> Users { set; get; }
public virtual DbSet<Role> Roles { set; get; }
public virtual DbSet<Contract> Contracts { set; get; } public virtual DbSet<Contract> Contracts { set; get; }
public virtual DbSet<Deal> Deals { set; get; } public virtual DbSet<Deal> Deals { set; get; }

View File

@ -0,0 +1,553 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Defendant")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Cases");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("DealId");
b.ToTable("CaseDeals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("LawyerId");
b.ToTable("CaseLawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Coast")
.HasColumnType("numeric");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Service")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Responsibilities")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Deals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("DealId");
b.ToTable("DealContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Information")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("UserId");
b.ToTable("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Experience")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("LawyerId");
b.ToTable("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Specializations");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("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
}
}
}

View File

@ -0,0 +1,66 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class Sec : Migration
{
/// <inheritdoc />
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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Role",
table: "Users",
newName: "RoleId");
migrationBuilder.CreateTable(
name: "Roles",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(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);
}
}
}

View File

@ -281,23 +281,6 @@ namespace CaseAccountingDataBaseImplement.Migrations
b.ToTable("LawyerContracts"); b.ToTable("LawyerContracts");
}); });
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Role", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Roles");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b => modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -336,13 +319,11 @@ namespace CaseAccountingDataBaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<int>("RoleId") b.Property<int>("Role")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("Users"); b.ToTable("Users");
}); });
@ -512,17 +493,6 @@ namespace CaseAccountingDataBaseImplement.Migrations
b.Navigation("User"); 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 => modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{ {
b.Navigation("CaseLawyers"); b.Navigation("CaseLawyers");
@ -553,11 +523,6 @@ namespace CaseAccountingDataBaseImplement.Migrations
b.Navigation("LawyerContracts"); b.Navigation("LawyerContracts");
}); });
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Role", b =>
{
b.Navigation("Users");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b => modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{ {
b.Navigation("Cases"); b.Navigation("Cases");

View File

@ -1,53 +0,0 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
namespace CaseAccountingDataBaseImplement.Models
{
public class Role : IRoleModel
{
public int Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
[ForeignKey("RoleId")]
public virtual List<User> Users { get; set; } = new();
public static Role? Create(RoleBindingModel? model)
{
if (model == null)
{
return null;
}
return new Role()
{
Id = model.Id,
Name = model.Name,
};
}
public void Update(RoleBindingModel? model)
{
if (model == null)
{
return;
}
Name = model.Name;
}
public RoleViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
};
}
}

View File

@ -1,5 +1,6 @@
using CaseAccountingContracts.BindingModels; using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels; using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Enum;
using CaseAccountingDataModels.Models; using CaseAccountingDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -22,8 +23,7 @@ namespace CaseAccountingDataBaseImplement.Models
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
[Required] [Required]
public int RoleId { get; set; } public Role Role { get; set; }
public virtual Role Role { get; set; } = new();
[ForeignKey("UserId")] [ForeignKey("UserId")]
public virtual List<Hearing> Hearings { get; set; } = new(); public virtual List<Hearing> Hearings { get; set; } = new();
@ -54,7 +54,7 @@ namespace CaseAccountingDataBaseImplement.Models
Id = model.Id, Id = model.Id,
Login = model.Login, Login = model.Login,
Password = model.Password, Password = model.Password,
RoleId = model.RoleId Role = model.Role
}; };
} }
@ -72,7 +72,7 @@ namespace CaseAccountingDataBaseImplement.Models
Id = Id, Id = Id,
Login = Login, Login = Login,
Password = Password, Password = Password,
RoleId = RoleId, Role = Role,
}; };
} }
} }

View File

@ -4,10 +4,11 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CaseAccountingDataModels.Models namespace CaseAccountingDataModels.Enum
{ {
public interface IRoleModel : IId public enum Role
{ {
string Name { get; } Provider = 0,
Customer = 1
} }
} }

View File

@ -1,4 +1,5 @@
using System; using CaseAccountingDataModels.Enum;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -10,6 +11,6 @@ namespace CaseAccountingDataModels.Models
{ {
string Login { get; } string Login { get; }
string Password { get; } string Password { get; }
int RoleId { get; } Role Role { get; }
} }
} }

View File

@ -35,7 +35,7 @@ namespace CaseAccountingRestApi.Controllers
{ {
try try
{ {
return _logic.ReadList(null); return _logic.ReadList(new CaseSearchModel { UserId = userId });
} }
catch (Exception) catch (Exception)
{ {
@ -43,32 +43,6 @@ namespace CaseAccountingRestApi.Controllers
} }
} }
/*[HttpGet]
public List<CaseViewModel>? 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] [HttpPost]
public void Create(CaseBindingModel model) public void Create(CaseBindingModel model)
{ {

View File

@ -35,7 +35,7 @@ namespace CaseAccountingRestApi.Controllers
{ {
try try
{ {
return _logic.ReadList(null); return _logic.ReadList(new ContractSearchModel { UserId = userId });
} }
catch (Exception) catch (Exception)
{ {

View File

@ -35,7 +35,7 @@ namespace CaseAccountingRestApi.Controllers
{ {
try try
{ {
return _logic.ReadList(null); return _logic.ReadList(new DealSearchModel { UserId = userId });
} }
catch (Exception) catch (Exception)
{ {

View File

@ -35,7 +35,7 @@ namespace CaseAccountingRestApi.Controllers
{ {
try try
{ {
return _logic.ReadList(null); return _logic.ReadList(new HearingSearchModel { UserId = userId });
} }
catch (Exception) catch (Exception)
{ {

View File

@ -3,6 +3,7 @@ using CaseAccountingContracts.BusinessLogicContracts;
using CaseAccountingContracts.SearchModels; using CaseAccountingContracts.SearchModels;
using CaseAccountingContracts.ViewModels; using CaseAccountingContracts.ViewModels;
using CaseAccountingDataBaseImplement.Models; using CaseAccountingDataBaseImplement.Models;
using CaseAccountingDataModels.Enum;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingRestApi.Controllers namespace CaseAccountingRestApi.Controllers
@ -27,7 +28,7 @@ namespace CaseAccountingRestApi.Controllers
{ {
Login = login, Login = login,
Password = password, Password = password,
//Role = role Role = role
}); });
} }
catch (Exception) catch (Exception)