Пытаемся прикрутить многие-ко-многим юристы.
This commit is contained in:
parent
4bea770d99
commit
79071f22b2
@ -23,6 +23,7 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
throw new Exception("403");
|
||||
}
|
||||
lawyerModel.UserId = APIUser.User.Id;
|
||||
lawyerModel.SpecializationId = 0;
|
||||
APIUser.PostRequest("api/lawyer/create", lawyerModel);
|
||||
Response.Redirect("/Home/Lawyers");
|
||||
}
|
||||
@ -109,6 +110,17 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
List<LawyerViewModel>? lawyers = APIUser.GetRequest<List<LawyerViewModel>>($"api/lawyer/getallbyuserandspecialization?userId={APIUser.User.Id}&specialization={specialization}");
|
||||
return lawyers ?? new();
|
||||
}
|
||||
|
||||
public List<CaseViewModel> GetAllCases()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<CaseViewModel>? _case = APIUser.GetRequest<List<CaseViewModel>>("api/lawyer/GetAllCases");
|
||||
return _case ?? new();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,5 +79,24 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
SpecializationViewModel? specialization = APIUser.GetRequest<SpecializationViewModel>($"api/specialization/get?id={id}");
|
||||
return specialization;
|
||||
}
|
||||
public IActionResult AddLawyer(int id)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.SpecializationId = id;
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void AddLawyer([FromBody] LawyerBindingModel lawyerModel)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("403");
|
||||
}
|
||||
APIUser.PostRequest("api/lawyer/update", lawyerModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
return;
|
||||
}
|
||||
<div>
|
||||
<a class="btn btn-secondary" asp-controller="Lawyer" asp-action="Create">Добавить юриста</a>
|
||||
<a class="btn btn-secondary" asp-controller="Lawyers" asp-action="Create">Добавить юриста</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
@ -46,10 +46,10 @@
|
||||
@item.Name @item.Surname @item.Patronymic
|
||||
</td>
|
||||
<td>
|
||||
@item.StudentCard
|
||||
@item.Experience
|
||||
</td>
|
||||
<td>
|
||||
@item.EducationStatusName
|
||||
@item.SpecializationName
|
||||
</td>
|
||||
<td>
|
||||
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Lawyer" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
|
||||
@ -64,4 +64,4 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<script src="~/js/lawyer/lawyers.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Lawyers/lawyers.js" asp-append-version="true"></script>
|
@ -44,6 +44,9 @@
|
||||
<td>
|
||||
@item.Name
|
||||
</td>
|
||||
<td>
|
||||
<a id="add-lawyer-button-@item.Id" class="btn btn-secondary" asp-controller="Specializations" asp-action="AddLawyer" asp-route-id="@item.Id">Назначить специализацию для юриста</a>
|
||||
</td>
|
||||
<td>
|
||||
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Specialization" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
|
||||
</td>
|
||||
@ -57,4 +60,4 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<script src="~/js/specialization/specializations.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Specializations/specializations.js" asp-append-version="true"></script>
|
@ -12,7 +12,7 @@
|
||||
</div>
|
||||
|
||||
<p class="mb-0">Название:</p>
|
||||
<input type="text" readonly value="@ViewBag.Document.Name" id="name-input" name="name" class="form-control mb-3" />
|
||||
<input type="text" readonly value="@ViewBag.Lawyer.Name" id="name-input" name="name" class="form-control mb-3" />
|
||||
|
||||
<button id="create-button" type="button" class="button-primary text-button">
|
||||
Сохранить привязку
|
||||
@ -23,7 +23,7 @@
|
||||
<table class="table table-bordered">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>Название группы:</th>
|
||||
<th>Название дела:</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="scrollable-table__tbody">
|
||||
@ -32,4 +32,4 @@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<script src="~/js/document/document-bind.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Lawyers/lawyer-bind.js" asp-append-version="true"></script>
|
@ -19,8 +19,24 @@
|
||||
<p class="mb-0">Опыт работы:</p>
|
||||
<input type="number" id="experience-input" name="experience" 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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="scrollable-table__tbody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button id="create-button" type="button" class="button-primary text-button">
|
||||
Создать
|
||||
</button>
|
||||
|
||||
<script src="~/js/lawyer/lawyer-create.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Lawyers/lawyer-create.js" asp-append-version="true"></script>
|
@ -33,4 +33,4 @@
|
||||
</button>
|
||||
}
|
||||
|
||||
<script src="~/js/lawyer/lawyer-update.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Lawyers/lawyer-update.js" asp-append-version="true"></script>
|
@ -54,4 +54,4 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<script src="~/js/Specializations/specialization-add-student.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Specializations/specialization-add-lawyer.js" asp-append-version="true"></script>
|
@ -4,48 +4,50 @@ const nameInput = document.getElementById("name-input");
|
||||
const currentLawyerId = document.getElementById("lawyer-data").dataset.id;
|
||||
var cases = [];
|
||||
var dataArray = [];
|
||||
var currentlawyer = null;
|
||||
var currentLawyer = null;
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
await $.ajax({
|
||||
url: "/lawyer/getallgroups",
|
||||
url: "/lawyer/getallcases",
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
groups = result;
|
||||
console.log(groups)
|
||||
cases = result;
|
||||
console.log(cases)
|
||||
});
|
||||
await $.ajax({
|
||||
url: `/document/get?id=${currentDocumentId}`,
|
||||
url: `/document/get?id=${currentLawyerId}`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
currentDocument = result;
|
||||
console.log(currentDocument)
|
||||
currentLawyer = result;
|
||||
console.log(currentLawyer)
|
||||
});
|
||||
groups.forEach((group) => createRowForGroupsTable(group));
|
||||
groups.forEach((case) => createRowForCasesTable(case));
|
||||
})
|
||||
|
||||
createBtn.addEventListener('click', () => {
|
||||
var documentGroupsUpdate = {
|
||||
"Id": currentDocument.id,
|
||||
"Name": currentDocument.name,
|
||||
"Date": currentDocument.date,
|
||||
"DocumentStudents": currentDocument.documentStudents,
|
||||
"DocumentGroups": dataArray,
|
||||
var lawyerCasesUpdate = {
|
||||
"Id": currentLawyer.id,
|
||||
"Name": currentLawyer.name,
|
||||
"Surname": currentLawyer.Surname,
|
||||
"Patronymic": currentLawyer.Patronymic,
|
||||
"SpecializationId": currentLawyer.SpecializationId,
|
||||
"LawyerContracts": currentLawyer.lawyerContracts,
|
||||
"LawyerCases": dataArray,
|
||||
}
|
||||
$.ajax({
|
||||
url: "/document/update",
|
||||
url: "/lawyer/update",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(documentGroupsUpdate)
|
||||
data: JSON.stringify(lawyerCasesUpdate)
|
||||
}).done(() => {
|
||||
window.location.href = "/Home/Documents";
|
||||
window.location.href = "/Home/Lawyers";
|
||||
});
|
||||
})
|
||||
|
||||
const createRowForGroupsTable = (group) => {
|
||||
const { id, name } = group;
|
||||
const createRowForCasesTable = (case) => {
|
||||
const { id, name, applicant, defendant, annotation, date, specializationId } = case;
|
||||
const row = tbody.insertRow();
|
||||
row.setAttribute("data-id", id);
|
||||
|
||||
@ -54,10 +56,10 @@ const createRowForGroupsTable = (group) => {
|
||||
const cell = row.insertCell();
|
||||
cell.textContent = value;
|
||||
});
|
||||
console.log(currentDocument)
|
||||
if (currentDocument.documentEdGroups?.find(x => parseInt(x.id) === parseInt(group.id))) {
|
||||
console.log(currentLawyer)
|
||||
if (currentLawyer.lawyerCases?.find(x => parseInt(x.id) === parseInt(case.id))) {
|
||||
row.classList.add("bg-success");
|
||||
dataArray.push(group);
|
||||
dataArray.push(case);
|
||||
}
|
||||
|
||||
row.addEventListener('click', () => addAndRemoveFromList(row));
|
||||
@ -73,9 +75,9 @@ const formatDate = (dateString) => {
|
||||
|
||||
const addAndRemoveFromList = (row) => {
|
||||
var id = parseInt(row.dataset.id);
|
||||
var index = dataArray.indexOf(groups.find(x => x.id === id));
|
||||
var index = dataArray.indexOf(cases.find(x => x.id === id));
|
||||
if (index === -1) {
|
||||
dataArray.push(groups.find(x => x.id === id));
|
||||
dataArray.push(cases.find(x => x.id === id));
|
||||
row.classList.add("bg-success");
|
||||
} else {
|
||||
dataArray.splice(index, 1);
|
||||
|
@ -10,12 +10,12 @@ var dataArray = [];
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
$.ajax({
|
||||
url: "/contract/getallbyuser",
|
||||
url: "/contracts/getallbyuser",
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
contracts = result;
|
||||
contracts.forEach((contract) => createRowForStudentsTable(contract));
|
||||
contracts.forEach((contract) => createRowForContractsTable(contract));
|
||||
});
|
||||
})
|
||||
|
||||
@ -27,8 +27,9 @@ createBtn.addEventListener('click', () => {
|
||||
"Experience": parseInt(experienceInput.value),
|
||||
"LawyerContracts": dataArray,
|
||||
}
|
||||
console.log(lawyer);
|
||||
$.ajax({
|
||||
url: "/lawyer/create",
|
||||
url: "/lawyers/create",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(lawyer)
|
||||
|
@ -9,14 +9,14 @@ var currentLawyer = null;
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
await $.ajax({
|
||||
url: "/contract/getallbyuser",
|
||||
url: "/contracts/getallbyuser",
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
contracts = result;
|
||||
});
|
||||
await $.ajax({
|
||||
url: `/lawyer/get?id=${currentLawyerId}`,
|
||||
url: `/lawyers/get?id=${currentLawyerId}`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
@ -25,7 +25,7 @@ window.addEventListener('load', async () => {
|
||||
contracts.forEach((contract) => createRowForContractsTable(contract));
|
||||
})
|
||||
|
||||
/*createBtn.addEventListener('click', () => {
|
||||
createBtn.addEventListener('click', () => {
|
||||
var lawyerCasesUpdate = {
|
||||
"Id": currentLawyer.id,
|
||||
"Service": serviceInput.value,
|
||||
@ -42,7 +42,7 @@ window.addEventListener('load', async () => {
|
||||
}).done(() => {
|
||||
window.location.href = "/Home/Lawyers";
|
||||
});
|
||||
})*/
|
||||
})
|
||||
|
||||
const createRowForContractsTable = (contract) => {
|
||||
const { id, service, coast, date} = contract;
|
||||
|
@ -10,7 +10,7 @@ removeButtons.forEach(function (button) {
|
||||
var result = confirm("Вы уверены, что хотите удалить эту запись?");
|
||||
if (result) {
|
||||
$.ajax({
|
||||
url: "/lawyer/delete",
|
||||
url: "/lawyers/delete",
|
||||
type: "POST",
|
||||
data: { Id: id }
|
||||
}).done(() => {
|
||||
|
@ -12,9 +12,12 @@ namespace CaseAccountingRestApi.Controllers
|
||||
{
|
||||
private readonly ILawyerLogic lawyerLogic;
|
||||
|
||||
public LawyerController(ILawyerLogic logic)
|
||||
private readonly ICaseLogic _caseLogic;
|
||||
|
||||
public LawyerController(ILawyerLogic logic, ICaseLogic caseLogic)
|
||||
{
|
||||
lawyerLogic = logic;
|
||||
_caseLogic = caseLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -81,5 +84,31 @@ namespace CaseAccountingRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CaseViewModel>? GetAllGroups()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _caseLogic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<LawyerViewModel>? GetAllByUserAndSpecialization(int userId, int specialization)
|
||||
{
|
||||
try
|
||||
{
|
||||
return lawyerLogic.ReadList(new LawyerSearchModel { UserId = userId, SpecializationId = specialization });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user