diff --git a/CaseAccounting/CaseAccountingCustomerView/Controllers/Lawyers.cs b/CaseAccounting/CaseAccountingCustomerView/Controllers/Lawyers.cs index 13bbee4..070493c 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Controllers/Lawyers.cs +++ b/CaseAccounting/CaseAccountingCustomerView/Controllers/Lawyers.cs @@ -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? lawyers = APIUser.GetRequest>($"api/lawyer/getallbyuserandspecialization?userId={APIUser.User.Id}&specialization={specialization}"); return lawyers ?? new(); } + + public List GetAllCases() + { + if (APIUser.User == null) + { + return new(); + } + List? _case = APIUser.GetRequest>("api/lawyer/GetAllCases"); + return _case ?? new(); + } + } } diff --git a/CaseAccounting/CaseAccountingCustomerView/Controllers/Specializations.cs b/CaseAccounting/CaseAccountingCustomerView/Controllers/Specializations.cs index 6872185..94d10f8 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Controllers/Specializations.cs +++ b/CaseAccounting/CaseAccountingCustomerView/Controllers/Specializations.cs @@ -79,5 +79,24 @@ namespace CaseAccountingCustomerView.Controllers SpecializationViewModel? specialization = APIUser.GetRequest($"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); + } } } diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Home/Lawyers.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Home/Lawyers.cshtml index 031ea96..cfbaba5 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Home/Lawyers.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Home/Lawyers.cshtml @@ -16,7 +16,7 @@ return; } @@ -46,10 +46,10 @@ @item.Name @item.Surname @item.Patronymic + @@ -57,4 +60,4 @@ } - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Bind.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Bind.cshtml index 5ab8b45..e85b9cc 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Bind.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Bind.cshtml @@ -12,7 +12,7 @@

Название:

- +
- @item.StudentCard + @item.Experience - @item.EducationStatusName + @item.SpecializationName Изменить @@ -64,4 +64,4 @@ } - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Home/Specializations.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Home/Specializations.cshtml index 4be00f1..2ef2668 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Home/Specializations.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Home/Specializations.cshtml @@ -44,6 +44,9 @@ @item.Name + Назначить специализацию для юриста + Изменить
- + @@ -32,4 +32,4 @@ } - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Create.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Create.cshtml index 8157214..750deeb 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Create.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Create.cshtml @@ -19,8 +19,24 @@

Опыт работы:

+
+
+
Название группы:Название дела:
+ + + + + + + + + +
УслугаЦенаДата
+ + + - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Update.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Update.cshtml index 17079e3..451dceb 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Update.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Lawyers/Update.cshtml @@ -33,4 +33,4 @@ } - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/AddLawyer.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/AddLawyer.cshtml index 7b45bed..1965f6b 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/AddLawyer.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/AddLawyer.cshtml @@ -54,4 +54,4 @@ } - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-bind.js b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-bind.js index c51f77c..c3cd4f0 100644 --- a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-bind.js +++ b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-bind.js @@ -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); diff --git a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-create.js b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-create.js index d9e95c5..3dc332e 100644 --- a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-create.js +++ b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-create.js @@ -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) diff --git a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-update.js b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-update.js index 8d9a58e..4c839ab 100644 --- a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-update.js +++ b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyer-update.js @@ -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; diff --git a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyers.js b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyers.js index 091e3c5..ae06a7d 100644 --- a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyers.js +++ b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Lawyers/lawyers.js @@ -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(() => { diff --git a/CaseAccounting/CaseAccountingRestApi/Controllers/LawyerController.cs b/CaseAccounting/CaseAccountingRestApi/Controllers/LawyerController.cs index 716033a..263d94a 100644 --- a/CaseAccounting/CaseAccountingRestApi/Controllers/LawyerController.cs +++ b/CaseAccounting/CaseAccountingRestApi/Controllers/LawyerController.cs @@ -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? GetAllGroups() + { + try + { + return _caseLogic.ReadList(null); + } + catch (Exception ex) + { + throw; + } + } + + [HttpGet] + public List? GetAllByUserAndSpecialization(int userId, int specialization) + { + try + { + return lawyerLogic.ReadList(new LawyerSearchModel { UserId = userId, SpecializationId = specialization }); + } + catch (Exception ex) + { + throw; + } + } } }