diff --git a/Nop.Plugin.Misc.AuctionPlugin/Content/Js/LiveAnnouncement.js b/Nop.Plugin.Misc.AuctionPlugin/Content/Js/LiveAnnouncement.js
index d69590f..14ea32f 100644
--- a/Nop.Plugin.Misc.AuctionPlugin/Content/Js/LiveAnnouncement.js
+++ b/Nop.Plugin.Misc.AuctionPlugin/Content/Js/LiveAnnouncement.js
@@ -1,9 +1,23 @@
-// Define the message handler library
-
-// SignalR connection setup
-$(function () {
+$(function () {
console.log("signalRJs Starts");
+ // AuctionStatus Enum
+ window.AuctionStatus = Object.freeze({
+ None: 0,
+ Active: 1,
+ FirstWarning: 2,
+ SecondWarning: 4,
+ SoldOut: 8,
+ NotSold: 16
+ });
+
+ // HUF Formatter
+ window.HUFFormatter = new Intl.NumberFormat('hu-HU', {
+ style: 'currency',
+ currency: 'HUF',
+ });
+
+ // SignalR connection setup
var connection = new signalR.HubConnectionBuilder()
.withUrl('/auctionhub')
.build();
@@ -19,11 +33,12 @@ $(function () {
}, 100000);
});
}
-
+
connection.onclose(function () {
start();
});
+ // Global function to send a message to the server
window.sendMessageToServer = function (messageType, senderId, data) {
var messageWrapper = {
MessageType: messageType,
@@ -42,94 +57,3 @@ $(function () {
start();
});
-
-// Function to send a message to the server
-
-
-
-//$(function () {
-
-// console.log("signalRJs Starts");
-// var connection = new signalR.HubConnectionBuilder()
-// .withUrl('/auctionhub')
-// .build();
-
-// connection.on('send', data => {
-// showannouncement(data);
-// });
-
-// function start() {
-// connection.start().catch(function (err) {
-// setTimeout(function () {
-// start();
-// }, 100000);
-// });
-// }
-
-// connection.onclose(function () {
-// start();
-// });
-
-// start();
-//});
-
-
-
-//function showannouncement(announcemant) {
-// console.log("announcement arrived!");
-// if (announcemant) {
-// toastr.options = {
-// "closeButton": true,
-// "debug": false,
-// "newestOnTop": false,
-// "progressBar": false,
-// "positionClass": "toast-bottom-right",
-// "preventDuplicates": false,
-// "onclick": null,
-// "showDuration": 300,
-// "hideDuration": 10000,
-// "timeOut": 100000,
-// "extendedTimeOut": 20000,
-// "showEasing": "swing",
-// "hideEasing": "linear",
-// "showMethod": "fadeIn",
-// "hideMethod": "fadeOut"
-// };
-
-// tostView = '
' + announcemant + '
'
-// toastr["info"](tostView);
-// $('.toast-info').css("background-color", "#008080");
-
-// toastr.options.onclick = function () {
-// $("html, body").animate(
-// { scrollTop: 0 },
-// 1000);
-// }
-
-// $(".toast").click(function () {
-// $("html, body").animate(
-// { scrollTop: 0 },
-// 1000);
-// });
-
-// $(".toast-info").click(function () {
-// $("html, body").animate(
-// { scrollTop: 0 },
-// 1000);
-// });
-
-// toastr.options = {
-// onclick: function () {
-// $("html, body").animate(
-// { scrollTop: 0 },
-// 1000);
-// }
-// }
-
-// $(".announcemantToast").on("click", function () {
-// $("html, body").animate(
-// { scrollTop: 0 },
-// 1000);
-// });
-// }
-//}
diff --git a/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs b/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs
index a130851..c07b3e9 100644
--- a/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs
+++ b/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs
@@ -1,5 +1,7 @@
-using Nop.Web.Framework.Models;
+using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
+using Nop.Web.Framework.Models;
using Nop.Web.Framework.Mvc.ModelBinding;
+using Nop.Web.Models.Catalog;
namespace Nop.Plugin.Misc.AuctionPlugin.Models
{
@@ -8,11 +10,14 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
public int ProductId { get; set; }
- public int ProductToAuctionMappingId { get; set; }
-
public DateTime StartDate { get; set; }
public bool IsActive { get; set; }
+ public AuctionDto CurrentAuction { get; set; }
+
+ public ProductDetailsModel ProductDetails { get; set; }
+
+
}
}
diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml
index 8ea9a77..e6730b0 100644
--- a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml
+++ b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml
@@ -46,12 +46,33 @@
Manage auction!
-
-
+ @{
+ if(Model.IsItemActive)
+ {
+
+
+
+ }
+ // else if(Model.)
+ // {
+
+ // }
+ else
+ {
+
+ }
+ }
+
+
+
}
@@ -116,13 +137,16 @@
document.getElementById("signalROpenItemButton").disabled = true;
event.preventDefault();
- var openItemMessage = {
- ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
- AdminId: bidBoxPageViewModel.CustomerId
- };
- var content = JSON.stringify(openItemMessage);
- console.log(content);
- sendMessageToServer("OpenItemRequestMessage", bidBoxPageViewModel.CustomerId, content);
+ handleAuctionStatusChange(AuctionStatus.Active);
+
+ return false;
+ });
+ $("#signalRCloseItemButton").on("click", function () {
+
+ document.getElementById("signalRCloseItemButton").disabled = true;
+ event.preventDefault();
+
+ handleAuctionStatusChange(AuctionStatus.SoldOut);
return false;
});
@@ -131,25 +155,48 @@
document.getElementById("signalRFirstWarningButton").disabled = true;
event.preventDefault();
- var itemFirstWarningMessage = {
- ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
- AdminId: bidBoxPageViewModel.CustomerId
- };
- var content = JSON.stringify(itemFirstWarningMessage);
- console.log(content);
- sendMessageToServer("FirstWarningMessage", bidBoxPageViewModel.CustomerId, content);
+ handleAuctionStatusChange(AuctionStatus.FirstWarning);
+
+ return false;
+ });
+ $("#signalRSecondWarningButton").on("click", function () {
+
+ document.getElementById("signalRSecondWarningButton").disabled = true;
+ event.preventDefault();
+
+ handleAuctionStatusChange(AuctionStatus.SecondWarning);
return false;
});
});
+ function handleAuctionStatusChange(auctionStatus) {
+
+ // Create the message object
+ var auctionMessage = {
+ ProductAuctionId: bidBoxPageViewModel.ProductToAuctionId,
+ AuctionStatus: auctionStatus
+ };
+
+ // Convert to JSON and log
+ var content = JSON.stringify(auctionMessage);
+ console.log(content);
+
+ // Send the message via SignalR
+ sendMessageToServer("AuctionProductStatusRequest", bidBoxPageViewModel.CustomerId, content);
+
+ return false;
+
+ }
+
+
function refreshPublicBidBox(data) {
- let HUFFormatter = new Intl.NumberFormat('hu-HU', {
- style: 'currency',
- currency: 'HUF',
- });
+ // let HUFFormatter = new Intl.NumberFormat('hu-HU', {
+ // style: 'currency',
+ // currency: 'HUF',
+ // });
var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId);
var budButtonElement = document.getElementById("signalRBidButton");