Осталось привязку
This commit is contained in:
commit
0c09e52c47
@ -1,4 +1,6 @@
|
||||
using CaseAccountingDataModels.Models;
|
||||
using CaseAccountingContracts.ViewModels;
|
||||
using CaseAccountingDataModels.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -20,5 +22,15 @@ namespace CaseAccountingContracts.BindingModels
|
||||
public int Id { get; set; }
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement
|
||||
Host=localhost;
|
||||
Port=5432;
|
||||
Database=CaseAccountingDatabase;
|
||||
Username=postgres;
|
||||
Password=postgres");
|
||||
Username=courseuser;
|
||||
Password=courseuser");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -139,6 +139,7 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
Annotation = Annotation,
|
||||
Date = Date,
|
||||
SpecializationId = SpecializationId,
|
||||
Specialization = Specialization.Name,
|
||||
UserId = UserId
|
||||
};
|
||||
}
|
||||
|
@ -64,7 +64,11 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
Responsibilities = model.Responsibilities,
|
||||
Date = model.Date,
|
||||
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()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
|
||||
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -119,5 +119,15 @@ namespace CaseAccountingProviderView.Controllers
|
||||
CaseViewModel? caseModel = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={id}");
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using CaseAccountingContracts.BindingModels;
|
||||
using CaseAccountingContracts.ViewModels;
|
||||
using CaseAccountingDataModels.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CaseAccountingProviderView.Controllers
|
||||
@ -23,6 +24,13 @@ namespace CaseAccountingProviderView.Controllers
|
||||
throw new Exception("403");
|
||||
}
|
||||
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);
|
||||
Response.Redirect("/Home/Deals");
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
<input type="text" id="annotation-input" name="annotation" class="form-control mb-3" />
|
||||
<p class="mb-0">Специализация:</p>
|
||||
<select id="specialization-select" name="specialization" class="form-control mb-3">
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
<button id="create-button" type="button" class="btn btn-primary text-button">
|
||||
|
@ -30,7 +30,6 @@
|
||||
<input type="text" id="annotation-input" name="annotation" class="form-control mb-3" />
|
||||
<p class="mb-0">Специализация:</p>
|
||||
<select id="specialization-select" name="specialization" class="form-control mb-3">
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
<button id="update-button" type="button" class="btn btn-primary text-button">
|
||||
|
@ -17,6 +17,25 @@
|
||||
<p class="mb-0">Дата составления:</p>
|
||||
<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>
|
||||
|
@ -16,7 +16,6 @@
|
||||
<input type="date" id="date-input" name="date" class="form-control mb-3" />
|
||||
<p class="mb-0">Дело:</p>
|
||||
<select id="case-select" name="case" class="form-control mb-3">
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
<button id="create-button" type="button" class="btn btn-primary text-button">
|
||||
|
@ -24,7 +24,6 @@
|
||||
<input type="date" id="date-input" name="date" class="form-control mb-3" />
|
||||
<p class="mb-0">Дело:</p>
|
||||
<select id="case-select" name="case" class="form-control mb-3">
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
<button id="update-button" type="button" class="btn btn-primary text-button">
|
||||
|
@ -16,3 +16,12 @@ html {
|
||||
body {
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
.scrollable-table {
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.scrollable-table tr {
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
@ -10,13 +10,12 @@ var specializations = [];
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
const specializationsResponse = await $.ajax({
|
||||
url: `/specialization/getall`,
|
||||
await $.ajax({
|
||||
url: `/case/getallspecializations`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
});
|
||||
specializations = specializationsResponse;
|
||||
|
||||
}).done((result) => {
|
||||
specializations = result;
|
||||
specializations.forEach((specialization) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = specialization.id;
|
||||
@ -24,6 +23,7 @@ window.addEventListener("load", async () => {
|
||||
specializationSelect.appendChild(option);
|
||||
specializationSelect.selectedIndex = -1;
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
@ -11,13 +11,12 @@ var specializations = [];
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
const specializationsResponse = await $.ajax({
|
||||
url: `/specialization/getall`,
|
||||
await $.ajax({
|
||||
url: `/case/getallspecializations`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
});
|
||||
specializations = specializationsResponse;
|
||||
|
||||
}).done((result) => {
|
||||
specializations = result;
|
||||
specializations.forEach((specialization) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = specialization.id;
|
||||
@ -25,6 +24,7 @@ window.addEventListener("load", async () => {
|
||||
specializationSelect.appendChild(option);
|
||||
specializationSelect.selectedIndex = -1;
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
@ -2,6 +2,37 @@
|
||||
const subjectInput = document.getElementById("subject-input");
|
||||
const responsibilitiesInput = document.getElementById("responsibilities-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", () => {
|
||||
if (!correctData()) {
|
||||
@ -26,7 +57,8 @@ createBtn.addEventListener("click", () => {
|
||||
let dealModel = {
|
||||
"Subject": subjectInput.value,
|
||||
"Responsibilities": responsibilitiesInput.value,
|
||||
"Date": new Date(dateInput.value)
|
||||
"Date": new Date(dateInput.value),
|
||||
"CaseViewModels": dataArray
|
||||
};
|
||||
console.log(dealModel)
|
||||
$.ajax({
|
||||
@ -38,3 +70,17 @@ createBtn.addEventListener("click", () => {
|
||||
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);
|
||||
}
|
@ -7,13 +7,12 @@ var cases = [];
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
const casesResponse = await $.ajax({
|
||||
url: `/specialization/getall`,
|
||||
$.ajax({
|
||||
url: "/case/getallbyuser",
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
});
|
||||
cases = casesResponse;
|
||||
|
||||
}).done((result) => {
|
||||
cases = result;
|
||||
cases.forEach((element) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = element.id;
|
||||
@ -21,6 +20,7 @@ window.addEventListener("load", async () => {
|
||||
caseSelect.appendChild(option);
|
||||
caseSelect.selectedIndex = -1;
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
@ -51,7 +51,7 @@ createBtn.addEventListener("click", () => {
|
||||
"CaseId": parseInt(caseSelect.value),
|
||||
"Date": new Date(dateInput.value)
|
||||
};
|
||||
console.log(dealModel)
|
||||
console.log(hearingModel)
|
||||
$.ajax({
|
||||
url: "/hearing/create",
|
||||
type: "POST",
|
||||
|
@ -8,13 +8,12 @@ var cases = [];
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
const casesResponse = await $.ajax({
|
||||
url: `/specialization/getall`,
|
||||
$.ajax({
|
||||
url: "/case/getallbyuser",
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
});
|
||||
cases = casesResponse;
|
||||
|
||||
}).done((result) => {
|
||||
cases = result;
|
||||
cases.forEach((element) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = element.id;
|
||||
@ -22,6 +21,7 @@ window.addEventListener("load", async () => {
|
||||
caseSelect.appendChild(option);
|
||||
caseSelect.selectedIndex = -1;
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
@ -19,6 +20,7 @@
|
||||
<ProjectReference Include="..\CaseAccountingBusinessLogics\CaseAccountingBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
|
||||
<ProjectReference Include="..\CaseAccountingDataBaseImplement\CaseAccountingDataBaseImplement.csproj" />
|
||||
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using CaseAccountingContracts.BindingModels;
|
||||
using CaseAccountingBusinessLogic.BusinessLogics;
|
||||
using CaseAccountingContracts.BindingModels;
|
||||
using CaseAccountingContracts.BusinessLogicContracts;
|
||||
using CaseAccountingContracts.SearchModels;
|
||||
using CaseAccountingContracts.ViewModels;
|
||||
@ -11,10 +12,12 @@ namespace CaseAccountingRestApi.Controllers
|
||||
public class CaseController : Controller
|
||||
{
|
||||
private readonly ICaseLogic _logic;
|
||||
private readonly ISpecializationLogic _specializationLogic;
|
||||
|
||||
public CaseController(ICaseLogic logic)
|
||||
public CaseController(ICaseLogic logic, ISpecializationLogic specializationLogic)
|
||||
{
|
||||
_logic = logic;
|
||||
_specializationLogic = specializationLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -43,6 +46,19 @@ namespace CaseAccountingRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<SpecializationViewModel>? GetAllSpecializations()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _specializationLogic.ReadList(null);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(CaseBindingModel model)
|
||||
{
|
||||
|
@ -44,19 +44,6 @@ namespace CaseAccountingRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<SpecializationViewModel>? GetAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
return specializationLogic.ReadList(null);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public void Create(SpecializationBindingModel model)
|
||||
|
@ -26,6 +26,8 @@ builder.Services.AddTransient<ILawyerLogic, LawyerLogic>();
|
||||
builder.Services.AddTransient<ISpecializationLogic, SpecializationLogic>();
|
||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||
|
||||
builder.Services.AddControllers().AddNewtonsoftJson();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
|
Loading…
Reference in New Issue
Block a user