fix update lawyer
This commit is contained in:
parent
2cca5bd9b9
commit
33d22bbb24
@ -61,6 +61,13 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
dict.Add(element.Id, _case);
|
||||
}
|
||||
lawyerModel.Cases = dict;
|
||||
var dictContr = new Dictionary<int, IContractModel>();
|
||||
foreach (var element in lawyerModel.ContractViewModels)
|
||||
{
|
||||
var contract = APIUser.GetRequest<ContractViewModel>($"api/contract/get?id={element.Id}");
|
||||
dictContr.Add(element.Id, contract);
|
||||
}
|
||||
lawyerModel.Contracts = dictContr;
|
||||
APIUser.PostRequest("api/lawyer/update", lawyerModel);
|
||||
Response.Redirect("/Home/Lawyers");
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
const createBtn = document.getElementById("create-button");
|
||||
const tbody = document.getElementById("scrollable-table__tbody");
|
||||
const serviceInput = document.getElementById("service-input");
|
||||
const coastInput = document.getElementById("coast-input");
|
||||
const nameInput = document.getElementById("name-input")
|
||||
const surnameInput = document.getElementById("surname-input")
|
||||
const patronymicInput = document.getElementById("patronymic-input")
|
||||
const experienceInput = document.getElementById("experience-input")
|
||||
const currentLawyerId = document.getElementById("lawyer-id").dataset.id;
|
||||
var contracts = [];
|
||||
var dataArray = [];
|
||||
@ -17,7 +19,7 @@ window.addEventListener('load', async () => {
|
||||
});
|
||||
console.log(currentLawyerId)
|
||||
await $.ajax({
|
||||
url: "/lawyers/get?id=${currentLawyerId}",
|
||||
url: `/lawyers/get?id=${currentLawyerId}`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
@ -36,23 +38,25 @@ window.addEventListener('load', async () => {
|
||||
cell.textContent = value;
|
||||
});
|
||||
console.log(currentLawyer);
|
||||
if (currentLawyer.ContractViewModels.find(x => parseInt(x.id) === parseInt(contract.id))) {
|
||||
/*if (currentLawyer.сontractViewModels.find(x => parseInt(x.id) === parseInt(contract.id))) {
|
||||
row.classList.add("bg-success");
|
||||
dataArray.push(contract);
|
||||
}
|
||||
}*/
|
||||
|
||||
row.addEventListener('click', () => addAndRemoveFromList(row));
|
||||
});
|
||||
})
|
||||
|
||||
createBtn.addEventListener('click', () => {
|
||||
console.log(dataArray);
|
||||
var lawyerCasesUpdate = {
|
||||
"Id": currentLawyer.id,
|
||||
"Service": serviceInput.value,
|
||||
"Coast": coastInput.value,
|
||||
"Date": currentLawyer.date,
|
||||
"ContractViewModels": dataArray,
|
||||
"LawyerCases": currentLawyer.lawyerCases,
|
||||
"Id": currentLawyerId,
|
||||
"Name": nameInput.value,
|
||||
"Surname": surnameInput.value,
|
||||
"Patronymic": patronymicInput.value,
|
||||
"Experience": parseInt(experienceInput.value),
|
||||
"SpecializationId": parseInt(currentLawyer.specializationId),
|
||||
"ContractViewModels": dataArray
|
||||
}
|
||||
$.ajax({
|
||||
url: "/lawyers/update",
|
||||
|
@ -66,7 +66,7 @@ const createRowForLawyersTable = (lawyer) => {
|
||||
const row = tbody.insertRow();
|
||||
row.setAttribute("data-id", id);
|
||||
|
||||
const cells = [name, surname, patronymic, experience, specialization];
|
||||
const cells = [name, surname, patronymic, experience, specialization ];
|
||||
cells.forEach((value) => {
|
||||
const cell = row.insertCell();
|
||||
cell.textContent = value;
|
||||
|
@ -114,6 +114,13 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
Case = context.Cases.First(y => y.Id == x.Key)
|
||||
}).ToList();
|
||||
}
|
||||
if (model.Contracts.Count > 0)
|
||||
{
|
||||
LawyerContracts = model.Contracts.Select(x => new LawyerContract
|
||||
{
|
||||
Contract = context.Contracts.First(y => y.Id == x.Key)
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateContracts(CaseAccountingDatabase context, LawyerBindingModel model)
|
||||
|
@ -12,7 +12,7 @@
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-lg bg-body-tertiary bg-primary" data-bs-theme="dark">
|
||||
<div class="container">
|
||||
<a class="navbar-brand text-white" asp-area="" asp-controller="Home" aspaction="Index">Юридическая фирма "Вас обманут"</a>
|
||||
<a class="navbar-brand text-white" asp-area="" asp-controller="Home" asp-action="Index">Юридическая фирма "Вас обманут"</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
Loading…
Reference in New Issue
Block a user