58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
const updateBtn = document.getElementById("update-button");
|
|
const subjectInput = document.getElementById("subject-input");
|
|
const responsibilitiesInput = document.getElementById("responsibilities-input");
|
|
const dateInput = document.getElementById("date-input");
|
|
const dealId = document.getElementById("vb-id").dataset.id;
|
|
|
|
window.addEventListener("load", async () => {
|
|
try {
|
|
await $.ajax({
|
|
url: `/deal/get?id=${dealId}`,
|
|
type: "GET",
|
|
contentType: "json"
|
|
}).done((result) => {
|
|
subjectInput.value = result.subject;
|
|
responsibilitiesInput.value = result.responsibilities;
|
|
dateInput.value = new Date(result.date);
|
|
});
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
});
|
|
|
|
updateBtn.addEventListener("click", () => {
|
|
if (!correctData()) {
|
|
return;
|
|
}
|
|
if (!validate()) {
|
|
return;
|
|
}
|
|
});
|
|
|
|
const correctData = function () {
|
|
|
|
return true;
|
|
};
|
|
|
|
const validate = function () {
|
|
|
|
return true;
|
|
};
|
|
|
|
updateBtn.addEventListener("click", () => {
|
|
let dealModel = {
|
|
"Id": parseInt(dealId),
|
|
"Subject": subjectInput.value,
|
|
"Responsibilities": responsibilitiesInput.value,
|
|
"Date": new Date(dateInput.value)
|
|
};
|
|
console.log(dealModel)
|
|
$.ajax({
|
|
url: "/deal/update",
|
|
type: "POST",
|
|
contentType: "application/json",
|
|
data: JSON.stringify(dealModel)
|
|
}).done(() => {
|
|
window.location.href = "/Home/Deals";
|
|
});
|
|
}); |