2023-05-18 23:32:19 +04:00
|
|
|
|
const createBtn = document.getElementById("create-button");
|
|
|
|
|
const informationInput = document.getElementById("information-input");
|
|
|
|
|
const dateInput = document.getElementById("date-input");
|
|
|
|
|
const caseSelect = document.getElementById("case-select");
|
|
|
|
|
|
2023-05-19 02:05:22 +04:00
|
|
|
|
var cases = [];
|
|
|
|
|
|
|
|
|
|
window.addEventListener("load", async () => {
|
|
|
|
|
try {
|
2023-05-19 14:39:49 +04:00
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/case/getallbyuser",
|
2023-05-19 02:05:22 +04:00
|
|
|
|
type: "GET",
|
|
|
|
|
contentType: "json"
|
2023-05-19 14:39:49 +04:00
|
|
|
|
}).done((result) => {
|
|
|
|
|
cases = result;
|
|
|
|
|
cases.forEach((element) => {
|
|
|
|
|
const option = document.createElement("option");
|
|
|
|
|
option.value = element.id;
|
|
|
|
|
option.innerHTML = "Дело №" + element.id;
|
|
|
|
|
caseSelect.appendChild(option);
|
|
|
|
|
caseSelect.selectedIndex = -1;
|
|
|
|
|
});
|
2023-05-19 02:05:22 +04:00
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2023-05-18 23:32:19 +04:00
|
|
|
|
createBtn.addEventListener("click", () => {
|
|
|
|
|
if (!correctData()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!validate()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const correctData = function () {
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const validate = function () {
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
createBtn.addEventListener("click", () => {
|
|
|
|
|
let hearingModel = {
|
|
|
|
|
"Information": informationInput.value,
|
|
|
|
|
"CaseId": parseInt(caseSelect.value),
|
|
|
|
|
"Date": new Date(dateInput.value)
|
|
|
|
|
};
|
2023-05-19 14:39:49 +04:00
|
|
|
|
console.log(hearingModel)
|
2023-05-18 23:32:19 +04:00
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/hearing/create",
|
|
|
|
|
type: "POST",
|
|
|
|
|
contentType: "application/json",
|
|
|
|
|
data: JSON.stringify(hearingModel)
|
|
|
|
|
}).done(() => {
|
|
|
|
|
window.location.href = "/Home/Hearings";
|
|
|
|
|
});
|
|
|
|
|
});
|