ПРИВЯЗКУ ДОДЕЛАЛ!!
This commit is contained in:
parent
cd661669c0
commit
7fcf90e006
@ -26,6 +26,10 @@ namespace CaseAccountingContracts.BindingModels
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public Dictionary<int, ICaseModel> Cases { get; set; } = new();
|
||||
|
||||
public List<CaseViewModel> CaseViewModels { get; set; } = new();
|
||||
|
||||
public Dictionary<int, IContractModel> Contracts { get; set; } = new();
|
||||
|
||||
public List<ContractViewModel> ContractViewModels { get; set; } = new();
|
||||
@ -33,9 +37,10 @@ namespace CaseAccountingContracts.BindingModels
|
||||
public LawyerBindingModel() { }
|
||||
|
||||
[JsonConstructor]
|
||||
public LawyerBindingModel(Dictionary<int, ContractViewModel> Contracts)
|
||||
public LawyerBindingModel(Dictionary<int, ContractViewModel> Contracts, Dictionary<int, CaseViewModel> Cases)
|
||||
{
|
||||
this.Contracts = Contracts.ToDictionary(x => x.Key, x => (IContractModel)x.Value);
|
||||
this.Cases = Cases.ToDictionary(x => x.Key, x => (ICaseModel)x.Value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,5 +24,7 @@ namespace CaseAccountingContracts.ViewModels
|
||||
public int UserId { get; set; }
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, IContractModel> Contracts { get; set; } = new();
|
||||
|
||||
public Dictionary<int, ICaseModel> Cases { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,13 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
throw new Exception("403");
|
||||
}
|
||||
lawyerModel.UserId = APIUser.User.Id;
|
||||
var dict = new Dictionary<int, ICaseModel>();
|
||||
foreach (var element in lawyerModel.CaseViewModels)
|
||||
{
|
||||
var _case = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={element.Id}");
|
||||
dict.Add(element.Id, _case);
|
||||
}
|
||||
lawyerModel.Cases = dict;
|
||||
APIUser.PostRequest("api/lawyer/update", lawyerModel);
|
||||
Response.Redirect("/Home/Lawyers");
|
||||
}
|
||||
@ -99,6 +106,16 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Bind([FromBody] LawyerBindingModel lawyerModel)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("403");
|
||||
}
|
||||
APIUser.PostRequest("api/lawyer/update", lawyerModel);
|
||||
}
|
||||
|
||||
public List<LawyerViewModel> GetAllByUserAndSpecialization(int specialization)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
|
@ -51,6 +51,9 @@
|
||||
<td>
|
||||
@item.Specialization
|
||||
</td>
|
||||
<td>
|
||||
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Lawyers" asp-action="Bind" asp-route-id="@item.Id">Привязка</a>
|
||||
</td>
|
||||
<td>
|
||||
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Lawyers" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
|
||||
</td>
|
||||
|
@ -8,7 +8,7 @@ var currentLawyer = null;
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
await $.ajax({
|
||||
url: "/lawyer/getallcases",
|
||||
url: "/lawyers/getallcases",
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
@ -16,28 +16,32 @@ window.addEventListener('load', async () => {
|
||||
console.log(cases)
|
||||
});
|
||||
await $.ajax({
|
||||
url: `/lawyer/get?id=${currentLawyerId}`,
|
||||
url: `/lawyers/get?id=${currentLawyerId}`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
currentLawyer = result;
|
||||
console.log(currentLawyer)
|
||||
});
|
||||
groups.forEach((case) => createRowForCasesTable(case));
|
||||
cases.forEach((_case) => createRowForCasesTable(_case));
|
||||
})
|
||||
|
||||
createBtn.addEventListener('click', () => {
|
||||
console.log("My data:")
|
||||
console.log(currentLawyer);
|
||||
console.log(dataArray);
|
||||
var lawyerCasesUpdate = {
|
||||
"Id": currentLawyer.id,
|
||||
"Name": currentLawyer.name,
|
||||
"Surname": currentLawyer.Surname,
|
||||
"Patronymic": currentLawyer.Patronymic,
|
||||
"SpecializationId": currentLawyer.SpecializationId,
|
||||
"ContractViewModels": currentLawyer.lawyerContracts,
|
||||
"LawyerCases": dataArray,
|
||||
"Surname": currentLawyer.surname,
|
||||
"Patronymic": currentLawyer.patronymic,
|
||||
"SpecializationId": currentLawyer.specializationId,
|
||||
"Experience": currentLawyer.experience,
|
||||
"ContractViewModels": currentLawyer.contractViewModels,
|
||||
"CaseViewModels": dataArray,
|
||||
}
|
||||
console.log(lawyerCasesUpdate);
|
||||
$.ajax({
|
||||
url: "/lawyer/update",
|
||||
url: "/lawyers/update",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(lawyerCasesUpdate)
|
||||
@ -46,8 +50,8 @@ createBtn.addEventListener('click', () => {
|
||||
});
|
||||
})
|
||||
|
||||
const createRowForCasesTable = (case) => {
|
||||
const { id, name, applicant, defendant, annotation, date, specializationId } = case;
|
||||
const createRowForCasesTable = (_case) => {
|
||||
const { id, name, applicant, defendant, annotation, date, specializationId } = _case;
|
||||
const row = tbody.insertRow();
|
||||
row.setAttribute("data-id", id);
|
||||
|
||||
@ -57,9 +61,9 @@ const createRowForCasesTable = (case) => {
|
||||
cell.textContent = value;
|
||||
});
|
||||
console.log(currentLawyer)
|
||||
if (currentLawyer.lawyerCases?.find(x => parseInt(x.id) === parseInt(case.id))) {
|
||||
if (currentLawyer.lawyerCases?.find(x => parseInt(x.id) === parseInt(_case.id))) {
|
||||
row.classList.add("bg-success");
|
||||
dataArray.push(case);
|
||||
dataArray.push(_case);
|
||||
}
|
||||
|
||||
row.addEventListener('click', () => addAndRemoveFromList(row));
|
||||
|
@ -123,9 +123,12 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
lawyer.Update(model);
|
||||
lawyer.Update(context, model);
|
||||
context.SaveChanges();
|
||||
if (model.Cases.Count > 0)
|
||||
{
|
||||
lawyer.UpdateContracts(context, model);
|
||||
}
|
||||
transaction.Commit();
|
||||
return lawyer.GetViewModel;
|
||||
}
|
||||
|
551
CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230519162440_migrBindTry1.Designer.cs
generated
Normal file
551
CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230519162440_migrBindTry1.Designer.cs
generated
Normal file
@ -0,0 +1,551 @@
|
||||
// <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("20230519162440_migrBindTry1")]
|
||||
partial class migrBindTry1
|
||||
{
|
||||
/// <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");
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CaseAccountingDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class migrBindTry1 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
551
CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230519172138_migrBindTry2.Designer.cs
generated
Normal file
551
CaseAccounting/CaseAccountingDataBaseImplement/Migrations/20230519172138_migrBindTry2.Designer.cs
generated
Normal file
@ -0,0 +1,551 @@
|
||||
// <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("20230519172138_migrBindTry2")]
|
||||
partial class migrBindTry2
|
||||
{
|
||||
/// <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");
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CaseAccountingDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class migrBindTry2 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -96,7 +96,7 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(LawyerBindingModel? model)
|
||||
public void Update(CaseAccountingDatabase context, LawyerBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -107,6 +107,13 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
Patronymic = model.Patronymic;
|
||||
Experience = model.Experience;
|
||||
SpecializationId = model.SpecializationId;
|
||||
if (model.Cases.Count > 0)
|
||||
{
|
||||
CaseLawyers = model.Cases.Select(x => new CaseLawyer
|
||||
{
|
||||
Case = context.Cases.First(y => y.Id == x.Key)
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateContracts(CaseAccountingDatabase context, LawyerBindingModel model)
|
||||
@ -141,6 +148,38 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCases(CaseAccountingDatabase context, LawyerBindingModel model)
|
||||
{
|
||||
var lawyerCases = context.CaseLawyers
|
||||
.Where(x => x.LawyerId == model.Id)
|
||||
.ToList();
|
||||
if (lawyerCases != null)
|
||||
{
|
||||
context.CaseLawyers
|
||||
.RemoveRange(lawyerCases
|
||||
.Where(x => !model.Cases
|
||||
.ContainsKey(x.CaseId))
|
||||
);
|
||||
context.SaveChanges();
|
||||
var lawyer = context.Lawyers
|
||||
.First(x => x.Id == Id);
|
||||
foreach (var lc in lawyerCases)
|
||||
{
|
||||
model.Cases.Remove(lc.CaseId);
|
||||
}
|
||||
foreach (var lc in model.Cases)
|
||||
{
|
||||
context.CaseLawyers.Add(new CaseLawyer
|
||||
{
|
||||
Lawyer = lawyer,
|
||||
Case = context.Cases.First(x => x.Id == lc.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_contracts = null;
|
||||
}
|
||||
}
|
||||
|
||||
public LawyerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
|
@ -86,7 +86,7 @@ namespace CaseAccountingRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CaseViewModel>? GetAllGroups()
|
||||
public List<CaseViewModel>? GetAllCases()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user