Compare commits

..

4 Commits

35 changed files with 1426 additions and 88 deletions

View File

@ -1,4 +1,6 @@
using CaseAccountingDataModels.Models; using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Models;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -20,5 +22,15 @@ namespace CaseAccountingContracts.BindingModels
public int Id { get; set; } public int Id { get; set; }
public Dictionary<int, ICaseModel> Cases { get; set; } = new(); public Dictionary<int, ICaseModel> Cases { get; set; } = new();
public List<CaseViewModel> CaseViewModels { get; set; } = new();
public DealBindingModel() { }
[JsonConstructor]
public DealBindingModel(Dictionary<int, CaseViewModel> Cases)
{
this.Cases = Cases.ToDictionary(x => x.Key, x => (ICaseModel)x.Value);
}
} }
} }

View File

@ -1,5 +1,6 @@
using CaseAccountingContracts.ViewModels; using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Models; using CaseAccountingDataModels.Models;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -19,7 +20,7 @@ namespace CaseAccountingContracts.BindingModels
public int Experience { get; set; } public int Experience { get; set; }
public int SpecializationId { get; set; } public int? SpecializationId { get; set; }
public int UserId { get; set; } public int UserId { get; set; }
@ -29,6 +30,13 @@ namespace CaseAccountingContracts.BindingModels
public List<ContractViewModel> ContractViewModels { get; set; } = new(); public List<ContractViewModel> ContractViewModels { get; set; } = new();
public LawyerBindingModel() { }
[JsonConstructor]
public LawyerBindingModel(Dictionary<int, ContractViewModel> Contracts)
{
this.Contracts = Contracts.ToDictionary(x => x.Key, x => (IContractModel)x.Value);
}
} }
} }

View File

@ -6,6 +6,10 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" /> <ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -18,7 +18,7 @@ namespace CaseAccountingContracts.ViewModels
public string Patronymic { get; set; } = string.Empty; public string Patronymic { get; set; } = string.Empty;
[DisplayName("Опыт работы")] [DisplayName("Опыт работы")]
public int Experience { get; set; } public int Experience { get; set; }
public int SpecializationId { get; set; } public int? SpecializationId { get; set; }
[DisplayName("Специализация")] [DisplayName("Специализация")]
public string Specialization { get; set; } = string.Empty; public string Specialization { get; set; } = string.Empty;
public int UserId { get; set; } public int UserId { get; set; }

View File

@ -1,5 +1,6 @@
using CaseAccountingContracts.BindingModels; using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels; using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingCustomerView.Controllers namespace CaseAccountingCustomerView.Controllers
@ -23,7 +24,14 @@ namespace CaseAccountingCustomerView.Controllers
throw new Exception("403"); throw new Exception("403");
} }
lawyerModel.UserId = APIUser.User.Id; lawyerModel.UserId = APIUser.User.Id;
lawyerModel.SpecializationId = 0; lawyerModel.SpecializationId = null;
var dict = new Dictionary<int, IContractModel>();
foreach (var element in lawyerModel.ContractViewModels)
{
var contract = APIUser.GetRequest<ContractViewModel>($"api/contract/get?id={element.Id}");
dict.Add(element.Id, contract);
}
lawyerModel.Contracts = dict;
APIUser.PostRequest("api/lawyer/create", lawyerModel); APIUser.PostRequest("api/lawyer/create", lawyerModel);
Response.Redirect("/Home/Lawyers"); Response.Redirect("/Home/Lawyers");
} }

View File

@ -49,10 +49,10 @@
@item.Experience @item.Experience
</td> </td>
<td> <td>
@item.SpecializationName @item.Specialization
</td> </td>
<td> <td>
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Lawyer" asp-action="Update" asp-route-id="@item.Id">Изменить</a> <a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Lawyers" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
</td> </td>
<td> <td>
<a id="remove-button-@item.Id" class="btn btn-secondary remove-btn" data-id="@item.Id">Удалить</a> <a id="remove-button-@item.Id" class="btn btn-secondary remove-btn" data-id="@item.Id">Удалить</a>

View File

@ -54,4 +54,4 @@
</div> </div>
} }
<script src="~/js/Specializations/specialization-add-lawyer.js" asp-append-version="true"></script> <script src="~/js/Specializations/specializations-add-lawyer.js" asp-append-version="true"></script>

View File

@ -16,6 +16,7 @@ window.addEventListener("load", async () => {
}); });
lawyers = lawyersResponse; lawyers = lawyersResponse;
console.log(lawyers);
lawyers.forEach((lawyer) => { lawyers.forEach((lawyer) => {
createLawyerOption(lawyer); createLawyerOption(lawyer);
}); });

View File

@ -0,0 +1,554 @@
// <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("20230519143905_migrSpecializationNull")]
partial class migrSpecializationNull
{
/// <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")
.IsRequired()
.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,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class migrSpecializationNull : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View 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("20230519145356_migrSpecializationNullAttempt2")]
partial class migrSpecializationNullAttempt2
{
/// <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
}
}
}

View File

@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class migrSpecializationNullAttempt2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Lawyers_Specializations_SpecializationId",
table: "Lawyers");
migrationBuilder.AlterColumn<int>(
name: "SpecializationId",
table: "Lawyers",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AddForeignKey(
name: "FK_Lawyers_Specializations_SpecializationId",
table: "Lawyers",
column: "SpecializationId",
principalTable: "Specializations",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Lawyers_Specializations_SpecializationId",
table: "Lawyers");
migrationBuilder.AlterColumn<int>(
name: "SpecializationId",
table: "Lawyers",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Lawyers_Specializations_SpecializationId",
table: "Lawyers",
column: "SpecializationId",
principalTable: "Specializations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -239,7 +239,7 @@ namespace CaseAccountingDataBaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<int>("SpecializationId") b.Property<int?>("SpecializationId")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("Surname") b.Property<string>("Surname")
@ -448,9 +448,7 @@ namespace CaseAccountingDataBaseImplement.Migrations
{ {
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization") b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Lawyers") .WithMany("Lawyers")
.HasForeignKey("SpecializationId") .HasForeignKey("SpecializationId");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Lawyers") .WithMany("Lawyers")

View File

@ -139,6 +139,7 @@ namespace CaseAccountingDataBaseImplement.Models
Annotation = Annotation, Annotation = Annotation,
Date = Date, Date = Date,
SpecializationId = SpecializationId, SpecializationId = SpecializationId,
Specialization = Specialization.Name,
UserId = UserId UserId = UserId
}; };
} }

View File

@ -64,7 +64,11 @@ namespace CaseAccountingDataBaseImplement.Models
Responsibilities = model.Responsibilities, Responsibilities = model.Responsibilities,
Date = model.Date, Date = model.Date,
UserId = model.UserId, UserId = model.UserId,
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User не существует") User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User не существует"),
CaseDeals = model.Cases.Select(x => new CaseDeal
{
Case = context.Cases.First(y => y.Id == x.Key)
}).ToList()
}; };
} }

View File

@ -27,9 +27,8 @@ namespace CaseAccountingDataBaseImplement.Models
[Required] [Required]
public int Experience { get; set; } public int Experience { get; set; }
[Required] public int? SpecializationId { get; set; }
public int SpecializationId { get; set; } public virtual Specialization? Specialization { get; set; } = new();
public virtual Specialization Specialization { get; set; } = new();
[Required] [Required]
public int UserId { get; set; } public int UserId { get; set; }
@ -38,6 +37,22 @@ namespace CaseAccountingDataBaseImplement.Models
[ForeignKey("LawyerId")] [ForeignKey("LawyerId")]
public virtual List<CaseLawyer> CaseLawyers { get; set; } = new(); public virtual List<CaseLawyer> CaseLawyers { get; set; } = new();
private Dictionary<int, ICaseModel>? _cases;
[NotMapped]
public Dictionary<int, ICaseModel> Cases
{
get
{
if (_cases == null)
{
_cases = CaseLawyers.ToDictionary(
x => x.CaseId, x => x.Case as ICaseModel);
}
return _cases;
}
}
[ForeignKey("LawyerId")] [ForeignKey("LawyerId")]
public virtual List<LawyerContract> LawyerContracts { get; set; } = new(); public virtual List<LawyerContract> LawyerContracts { get; set; } = new();
@ -71,9 +86,13 @@ namespace CaseAccountingDataBaseImplement.Models
Patronymic = model.Patronymic, Patronymic = model.Patronymic,
Experience = model.Experience, Experience = model.Experience,
SpecializationId = model.SpecializationId, SpecializationId = model.SpecializationId,
Specialization = context.Specializations.FirstOrDefault(x => x.Id == model.SpecializationId) ?? throw new Exception("specialization not found"), Specialization = context.Specializations.FirstOrDefault(x => model.SpecializationId.HasValue && x.Id == model.SpecializationId),
UserId = model.UserId, UserId = model.UserId,
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User not found") User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User not found"),
LawyerContracts = model.Contracts.Select(x => new LawyerContract
{
Contract = context.Contracts.First(y => y.Id == x.Key)
}).ToList()
}; };
} }
@ -130,7 +149,8 @@ namespace CaseAccountingDataBaseImplement.Models
Patronymic = Patronymic, Patronymic = Patronymic,
Experience = Experience, Experience = Experience,
SpecializationId = SpecializationId, SpecializationId = SpecializationId,
UserId = UserId UserId = UserId,
Specialization = Specialization?.Name ?? "Не указан"
}; };
} }
} }

View File

@ -12,7 +12,7 @@ namespace CaseAccountingDataModels.Models
string Surname { get; } string Surname { get; }
string Patronymic { get; } string Patronymic { get; }
int Experience { get; } int Experience { get; }
int SpecializationId { get; } int? SpecializationId { get; }
int UserId { get; } int UserId { get; }
Dictionary<int, IContractModel> Contracts { get; } Dictionary<int, IContractModel> Contracts { get; }
} }

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -12,6 +12,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" /> <ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -119,5 +119,15 @@ namespace CaseAccountingProviderView.Controllers
CaseViewModel? caseModel = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={id}"); CaseViewModel? caseModel = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={id}");
return caseModel; return caseModel;
} }
public List<SpecializationViewModel> GetAllSpecializations()
{
if (APIUser.User == null)
{
return new();
}
List<SpecializationViewModel>? specializationModel = APIUser.GetRequest<List<SpecializationViewModel>>($"api/case/getallspecializations");
return specializationModel ?? new();
}
} }
} }

View File

@ -1,5 +1,6 @@
using CaseAccountingContracts.BindingModels; using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels; using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingProviderView.Controllers namespace CaseAccountingProviderView.Controllers
@ -23,6 +24,13 @@ namespace CaseAccountingProviderView.Controllers
throw new Exception("403"); throw new Exception("403");
} }
dealModel.UserId = APIUser.User.Id; dealModel.UserId = APIUser.User.Id;
var dict = new Dictionary<int, ICaseModel>();
foreach (var element in dealModel.CaseViewModels)
{
var caseModel = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={element.Id}");
dict.Add(element.Id, caseModel);
}
dealModel.Cases = dict;
APIUser.PostRequest("api/deal/create", dealModel); APIUser.PostRequest("api/deal/create", dealModel);
Response.Redirect("/Home/Deals"); Response.Redirect("/Home/Deals");
} }

View File

@ -22,7 +22,6 @@
<input type="text" id="annotation-input" name="annotation" class="form-control mb-3" /> <input type="text" id="annotation-input" name="annotation" class="form-control mb-3" />
<p class="mb-0">Специализация:</p> <p class="mb-0">Специализация:</p>
<select id="specialization-select" name="specialization" class="form-control mb-3"> <select id="specialization-select" name="specialization" class="form-control mb-3">
<option></option>
</select> </select>
<button id="create-button" type="button" class="btn btn-primary text-button"> <button id="create-button" type="button" class="btn btn-primary text-button">

View File

@ -30,7 +30,6 @@
<input type="text" id="annotation-input" name="annotation" class="form-control mb-3" /> <input type="text" id="annotation-input" name="annotation" class="form-control mb-3" />
<p class="mb-0">Специализация:</p> <p class="mb-0">Специализация:</p>
<select id="specialization-select" name="specialization" class="form-control mb-3"> <select id="specialization-select" name="specialization" class="form-control mb-3">
<option></option>
</select> </select>
<button id="update-button" type="button" class="btn btn-primary text-button"> <button id="update-button" type="button" class="btn btn-primary text-button">

View File

@ -17,6 +17,25 @@
<p class="mb-0">Дата составления:</p> <p class="mb-0">Дата составления:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" /> <input type="date" id="date-input" name="date" class="form-control mb-3" />
<div>
<div class="scrollable-table">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th>Номер дела:</th>
<th>Истец:</th>
<th>Ответчик:</th>
<th>Дата составления:</th>
<th>Примечание:</th>
<th>Специализация:</th>
</tr>
</thead>
<tbody id="scrollable-table__tbody">
</tbody>
</table>
</div>
</div>
<button id="create-button" type="button" class="btn btn-primary text-button"> <button id="create-button" type="button" class="btn btn-primary text-button">
Создать Создать
</button> </button>

View File

@ -16,7 +16,6 @@
<input type="date" id="date-input" name="date" class="form-control mb-3" /> <input type="date" id="date-input" name="date" class="form-control mb-3" />
<p class="mb-0">Дело:</p> <p class="mb-0">Дело:</p>
<select id="case-select" name="case" class="form-control mb-3"> <select id="case-select" name="case" class="form-control mb-3">
<option></option>
</select> </select>
<button id="create-button" type="button" class="btn btn-primary text-button"> <button id="create-button" type="button" class="btn btn-primary text-button">

View File

@ -24,7 +24,6 @@
<input type="date" id="date-input" name="date" class="form-control mb-3" /> <input type="date" id="date-input" name="date" class="form-control mb-3" />
<p class="mb-0">Дело:</p> <p class="mb-0">Дело:</p>
<select id="case-select" name="case" class="form-control mb-3"> <select id="case-select" name="case" class="form-control mb-3">
<option></option>
</select> </select>
<button id="update-button" type="button" class="btn btn-primary text-button"> <button id="update-button" type="button" class="btn btn-primary text-button">

View File

@ -16,3 +16,12 @@ html {
body { body {
margin-bottom: 60px; margin-bottom: 60px;
} }
.scrollable-table {
max-height: 400px;
overflow-y: auto;
}
.scrollable-table tr {
transition: background-color 0.3s ease;
}

View File

@ -10,13 +10,12 @@ var specializations = [];
window.addEventListener("load", async () => { window.addEventListener("load", async () => {
try { try {
const specializationsResponse = await $.ajax({ await $.ajax({
url: `/specialization/getall`, url: `/case/getallspecializations`,
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}); }).done((result) => {
specializations = specializationsResponse; specializations = result;
specializations.forEach((specialization) => { specializations.forEach((specialization) => {
const option = document.createElement("option"); const option = document.createElement("option");
option.value = specialization.id; option.value = specialization.id;
@ -24,6 +23,7 @@ window.addEventListener("load", async () => {
specializationSelect.appendChild(option); specializationSelect.appendChild(option);
specializationSelect.selectedIndex = -1; specializationSelect.selectedIndex = -1;
}); });
});
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }

View File

@ -11,13 +11,12 @@ var specializations = [];
window.addEventListener("load", async () => { window.addEventListener("load", async () => {
try { try {
const specializationsResponse = await $.ajax({ await $.ajax({
url: `/specialization/getall`, url: `/case/getallspecializations`,
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}); }).done((result) => {
specializations = specializationsResponse; specializations = result;
specializations.forEach((specialization) => { specializations.forEach((specialization) => {
const option = document.createElement("option"); const option = document.createElement("option");
option.value = specialization.id; option.value = specialization.id;
@ -25,6 +24,7 @@ window.addEventListener("load", async () => {
specializationSelect.appendChild(option); specializationSelect.appendChild(option);
specializationSelect.selectedIndex = -1; specializationSelect.selectedIndex = -1;
}); });
});
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }

View File

@ -2,6 +2,37 @@
const subjectInput = document.getElementById("subject-input"); const subjectInput = document.getElementById("subject-input");
const responsibilitiesInput = document.getElementById("responsibilities-input"); const responsibilitiesInput = document.getElementById("responsibilities-input");
const dateInput = document.getElementById("date-input"); const dateInput = document.getElementById("date-input");
const tbody = document.getElementById("scrollable-table__tbody")
var cases = [];
var dataArray = [];
window.addEventListener("load", async () => {
try {
await $.ajax({
url: `/case/getallbyuser`,
type: "GET",
contentType: "json"
}).done((result) => {
cases = result;
cases.forEach((caseModel) => {
const { id, name, applicant, defendant, annotation, date, specialization } = caseModel;
const row = tbody.insertRow();
row.setAttribute("data-id", id);
const cells = [name, applicant, defendant, annotation, date, specialization];
cells.forEach((value) => {
const cell = row.insertCell();
cell.textContent = value;
});
row.addEventListener('click', () => addAndRemoveFromList(row));
});
});
} catch (error) {
console.error(error);
}
});
createBtn.addEventListener("click", () => { createBtn.addEventListener("click", () => {
if (!correctData()) { if (!correctData()) {
@ -26,7 +57,8 @@ createBtn.addEventListener("click", () => {
let dealModel = { let dealModel = {
"Subject": subjectInput.value, "Subject": subjectInput.value,
"Responsibilities": responsibilitiesInput.value, "Responsibilities": responsibilitiesInput.value,
"Date": new Date(dateInput.value) "Date": new Date(dateInput.value),
"CaseViewModels": dataArray
}; };
console.log(dealModel) console.log(dealModel)
$.ajax({ $.ajax({
@ -38,3 +70,17 @@ createBtn.addEventListener("click", () => {
window.location.href = "/Home/Deals"; window.location.href = "/Home/Deals";
}); });
}); });
const addAndRemoveFromList = (row) => {
var id = parseInt(row.dataset.id);
console.log(cases.find(x => x.id === id))
var index = dataArray.indexOf(cases.find(x => x.id === id));
if (index === -1) {
dataArray.push(cases.find(x => x.id === id));
row.classList.add("bg-primary");
} else {
dataArray.splice(index, 1);
row.classList.remove("bg-primary");
}
console.log(dataArray);
}

View File

@ -7,13 +7,12 @@ var cases = [];
window.addEventListener("load", async () => { window.addEventListener("load", async () => {
try { try {
const casesResponse = await $.ajax({ $.ajax({
url: `/specialization/getall`, url: "/case/getallbyuser",
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}); }).done((result) => {
cases = casesResponse; cases = result;
cases.forEach((element) => { cases.forEach((element) => {
const option = document.createElement("option"); const option = document.createElement("option");
option.value = element.id; option.value = element.id;
@ -21,6 +20,7 @@ window.addEventListener("load", async () => {
caseSelect.appendChild(option); caseSelect.appendChild(option);
caseSelect.selectedIndex = -1; caseSelect.selectedIndex = -1;
}); });
});
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
@ -51,7 +51,7 @@ createBtn.addEventListener("click", () => {
"CaseId": parseInt(caseSelect.value), "CaseId": parseInt(caseSelect.value),
"Date": new Date(dateInput.value) "Date": new Date(dateInput.value)
}; };
console.log(dealModel) console.log(hearingModel)
$.ajax({ $.ajax({
url: "/hearing/create", url: "/hearing/create",
type: "POST", type: "POST",

View File

@ -8,13 +8,12 @@ var cases = [];
window.addEventListener("load", async () => { window.addEventListener("load", async () => {
try { try {
const casesResponse = await $.ajax({ $.ajax({
url: `/specialization/getall`, url: "/case/getallbyuser",
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}); }).done((result) => {
cases = casesResponse; cases = result;
cases.forEach((element) => { cases.forEach((element) => {
const option = document.createElement("option"); const option = document.createElement("option");
option.value = element.id; option.value = element.id;
@ -22,6 +21,7 @@ window.addEventListener("load", async () => {
caseSelect.appendChild(option); caseSelect.appendChild(option);
caseSelect.selectedIndex = -1; caseSelect.selectedIndex = -1;
}); });
});
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -7,6 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -19,6 +20,7 @@
<ProjectReference Include="..\CaseAccountingBusinessLogics\CaseAccountingBusinessLogic.csproj" /> <ProjectReference Include="..\CaseAccountingBusinessLogics\CaseAccountingBusinessLogic.csproj" />
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" /> <ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
<ProjectReference Include="..\CaseAccountingDataBaseImplement\CaseAccountingDataBaseImplement.csproj" /> <ProjectReference Include="..\CaseAccountingDataBaseImplement\CaseAccountingDataBaseImplement.csproj" />
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,5 @@
using CaseAccountingContracts.BindingModels; using CaseAccountingBusinessLogic.BusinessLogics;
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.BusinessLogicContracts; using CaseAccountingContracts.BusinessLogicContracts;
using CaseAccountingContracts.SearchModels; using CaseAccountingContracts.SearchModels;
using CaseAccountingContracts.ViewModels; using CaseAccountingContracts.ViewModels;
@ -11,10 +12,12 @@ namespace CaseAccountingRestApi.Controllers
public class CaseController : Controller public class CaseController : Controller
{ {
private readonly ICaseLogic _logic; private readonly ICaseLogic _logic;
private readonly ISpecializationLogic _specializationLogic;
public CaseController(ICaseLogic logic) public CaseController(ICaseLogic logic, ISpecializationLogic specializationLogic)
{ {
_logic = logic; _logic = logic;
_specializationLogic = specializationLogic;
} }
[HttpGet] [HttpGet]
@ -43,6 +46,19 @@ namespace CaseAccountingRestApi.Controllers
} }
} }
[HttpGet]
public List<SpecializationViewModel>? GetAllSpecializations()
{
try
{
return _specializationLogic.ReadList(null);
}
catch (Exception)
{
throw;
}
}
[HttpPost] [HttpPost]
public void Create(CaseBindingModel model) public void Create(CaseBindingModel model)
{ {

View File

@ -44,19 +44,6 @@ namespace CaseAccountingRestApi.Controllers
} }
} }
[HttpGet]
public List<SpecializationViewModel>? GetAll()
{
try
{
return specializationLogic.ReadList(null);
}
catch (Exception)
{
throw;
}
}
[HttpPost] [HttpPost]
public void Create(SpecializationBindingModel model) public void Create(SpecializationBindingModel model)

View File

@ -26,6 +26,8 @@ builder.Services.AddTransient<ILawyerLogic, LawyerLogic>();
builder.Services.AddTransient<ISpecializationLogic, SpecializationLogic>(); builder.Services.AddTransient<ISpecializationLogic, SpecializationLogic>();
builder.Services.AddTransient<IUserLogic, UserLogic>(); builder.Services.AddTransient<IUserLogic, UserLogic>();
builder.Services.AddControllers().AddNewtonsoftJson();
builder.Services.AddControllers(); builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();