diff --git a/AddHotelpage.html b/AddHotelpage.html index b04cbb8..5499622 100644 --- a/AddHotelpage.html +++ b/AddHotelpage.html @@ -135,7 +135,7 @@

Manage Hotel Details

- +
diff --git a/controller/HotelDetailsController.js b/controller/HotelDetailsController.js index 84e183e..8b0f94c 100644 --- a/controller/HotelDetailsController.js +++ b/controller/HotelDetailsController.js @@ -5,7 +5,7 @@ //create hotel details object function hotelDetails(){ - + const hotelId = $('#hotel_Id').val(); const hotelName = $('#hotel_Name').val(); const hotelCategory = $('#hotel_Category').val(); @@ -46,6 +46,7 @@ function hotelDetails(){ return hotelDetails; } +//hotel details save event $("#hotel-save-btn").click(function (e) { //get returned hotel Details object @@ -67,4 +68,80 @@ $("#hotel-save-btn").click(function (e) { alert("An error occurred: " + error); } }); +}); + +//get all hotel details +function getAllHotelDetails(){ + $.ajax({ + url: baseURL + "hotel/getAll", + method: "GET", + success: function (response) { + $("#hotel-details-tbl tbody").empty(); + response.forEach(element => { + let rawData = ` + + + + + + + + + + + `; + $("#Guide-Details-table tbody").append(rawData); + }); + }, + error: function (xhr, status, error) { + alert("An error occurred: " + error); + } + }); +} + +$("#hotel-update-btn").click(function (e) { + + //get returned hotel Details object + const hotelDetailsObj=hotelDetails(); + + // Create Put Request + $.ajax({ + url: baseURL + "hotel/update", + method: "put", + data: JSON.stringify(hotelDetailsObj), + contentType: "application/json", + dataType: "json", + success: function (response) { + if (response.code == 200) { + alert(response.message); + }; + }, + error: function (xhr, status, error) { + console.error(error); + alert("An error occurred: " + error); + } + }); +}); + +//delete hotel details event +$("#hotel-delete-btn").click(function (e) { + const hotelId = $('#hotel_Id').val(); + const choice = confirm("Do you want to delete this Data ?"); + if(hotelId==""){ + alert("Hotel Id is Empty"); + return; + }else if(choice == true){ + $.ajax({ + url: baseURL + "hotel/" + hotelId, + method: "delete", + dataType: "json", + success: function (response) { + alert(response.message); + }, + error: function (xhr, status, error) { + alert("Package Deleted Succesfully"); + } + }); + }else{ + } }); \ No newline at end of file
HotelID
${element.data.}${element.data.} ${element.data.} ${element.data.} ${element.data.} ${element.data.} ${element.data.} ${element.data.} ${element.data.} ${element.data.}