Промежутный коммит, исправлены баги

This commit is contained in:
maxnes3 2023-05-19 14:39:49 +04:00
parent 4bea770d99
commit f03bb241c0
14 changed files with 88 additions and 67 deletions

View File

@ -79,5 +79,16 @@ namespace CaseAccountingCustomerView.Controllers
SpecializationViewModel? specialization = APIUser.GetRequest<SpecializationViewModel>($"api/specialization/get?id={id}"); SpecializationViewModel? specialization = APIUser.GetRequest<SpecializationViewModel>($"api/specialization/get?id={id}");
return specialization; return specialization;
} }
}
public List<SpecializationViewModel> GetAll()
{
if (APIUser.User == null)
{
return new();
}
List<SpecializationViewModel>? specializations = APIUser.GetRequest<List<SpecializationViewModel>>($"api/specialization/getall");
return specializations ?? new();
}
}
} }

View File

@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement
Host=localhost; Host=localhost;
Port=5432; Port=5432;
Database=CaseAccountingDatabase; Database=CaseAccountingDatabase;
Username=postgres; Username=courseuser;
Password=postgres"); Password=courseuser");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

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

@ -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

@ -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

@ -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

@ -10,19 +10,19 @@ 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; option.innerHTML = specialization.name;
option.innerHTML = specialization.name; 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,19 +11,19 @@ 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; option.innerHTML = specialization.name;
option.innerHTML = specialization.name; specializationSelect.appendChild(option);
specializationSelect.appendChild(option); specializationSelect.selectedIndex = -1;
specializationSelect.selectedIndex = -1; });
}); });
} catch (error) { } catch (error) {
console.error(error); console.error(error);

View File

@ -7,19 +7,19 @@ 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; option.innerHTML = "Дело №" + element.id;
option.innerHTML = "Дело №" + element.id; 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,19 +8,19 @@ 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; option.innerHTML = "Дело №" + element.id;
option.innerHTML = "Дело №" + element.id; 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,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)