61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
$(document).ready(function () {
|
|
$("#EditData").click(function () {
|
|
$(".btnEdit .spinner-loading").css("display", "flex");
|
|
var name = $("#bankNameEdit").val();
|
|
|
|
if (name) {
|
|
editBank(name);
|
|
} else {
|
|
showAlertMessage('.alert-msg', 'نام بانک را مشخص کنید.', 3500);
|
|
}
|
|
});
|
|
});
|
|
|
|
function showAlertMessage(selector, message, timeout) {
|
|
$(selector).show();
|
|
$(selector + ' p').text(message);
|
|
setTimeout(function () {
|
|
$(selector).hide();
|
|
$(selector + ' p').text('');
|
|
}, timeout);
|
|
}
|
|
|
|
function editBank(name) {
|
|
var id = $("#bankIdEdit").val();
|
|
console.log(id);
|
|
|
|
var formData = new FormData();
|
|
formData.append('command.id', id);
|
|
formData.append('command.BankName', name);
|
|
formData.append('command.BankLogoPictureFile', $('#BankLogoPictureFile')[0].files[0]);
|
|
|
|
|
|
$.ajax({
|
|
async: false,
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
url: editBankUrl,
|
|
data: formData,
|
|
processData: false, // Important for FormData
|
|
contentType: false, // Important for FormData
|
|
headers: { 'RequestVerificationToken': antiForgeryToken },
|
|
success: function (response) {
|
|
console.log(response);
|
|
if (response.success) {
|
|
showAlertMessage('.alert-success-msg', 'بانک با موفقیت ویرایش شد.', 3500);
|
|
setTimeout(function () {
|
|
$(".btnEdit .spinner-loading").css("display", "none");
|
|
location.reload();
|
|
}, 500);
|
|
|
|
} else {
|
|
showAlertMessage('.alert-msg', response.message, 3500);
|
|
$(".btnEdit .spinner-loading").css("display", "none");
|
|
}
|
|
},
|
|
error: function () {
|
|
showAlertMessage('.alert-msg', response.message, 3500);
|
|
$(".btnEdit .spinner-loading").css("display", "none");
|
|
}
|
|
});
|
|
} |