From 7246d86e76bfbadd08b0336e7e2a53da8dc7c38f Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 30 Nov 2024 20:41:25 +0100 Subject: [PATCH] =?UTF-8?q?ha=20eny=C3=A9m=20a=20bid=20akkor=20nem=20csili?= =?UTF-8?q?ngel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/Js/MgMessageHandler.js | 7 +++---- .../Controllers/AuctionController.cs | 8 +++++--- .../Models/LiveScreenViewModel.cs | 1 + .../Views/LiveScreen.cshtml | 12 +++++++++++- .../Views/PublicProductBidBox.cshtml | 4 +++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js b/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js index 48a93e4..d3787c7 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js +++ b/Nop.Plugin.Misc.AuctionPlugin/Content/Js/MgMessageHandler.js @@ -46,8 +46,8 @@ if (publicProductBidBox) { - var audio = new Audio('../Plugins/Misc.AuctionPlugin/Content/ding.mp3'); - audio.play(); + //var audio = new Audio('../Plugins/Misc.AuctionPlugin/Content/ding.mp3'); + //audio.play(); refreshPublicBidBox(myObject); } if (publicInfo) { @@ -56,8 +56,7 @@ } if (liveScreen) { - var audio = new Audio('../../Plugins/Misc.AuctionPlugin/Content/ding.mp3'); - audio.play(); + updateOnBid(myObject); } else { diff --git a/Nop.Plugin.Misc.AuctionPlugin/Controllers/AuctionController.cs b/Nop.Plugin.Misc.AuctionPlugin/Controllers/AuctionController.cs index 8aa1344..a22304c 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Controllers/AuctionController.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Controllers/AuctionController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Nop.Core; using Nop.Core.Domain.Catalog; using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities; using Nop.Plugin.Misc.AuctionPlugin.Models; @@ -10,7 +11,7 @@ using Nop.Web.Models.Catalog; namespace Nop.Plugin.Misc.AuctionPlugin.Controllers; -public class AuctionController(AuctionService auctionService, ILogger logger, IProductService productService, MyProductModelFactory productModelFactory) +public class AuctionController(AuctionService auctionService, ILogger logger, IProductService productService, MyProductModelFactory productModelFactory, IWorkContext _workContext) : BasePluginController { // GET @@ -60,7 +61,8 @@ public class AuctionController(AuctionService auctionService, ILogger logger, IP var auctionDto = await auctionService.GetAuctionDtoWithAuctionBids(auctionId, true, 5); //A javascript-ben az első 6-ot vágod le, melyik a valid? - J. var activeMapping = auctionDto?.ProductToAuctionDtos.MinBy(x => x.SortIndex); var isAnyItemLive = activeMapping != null; - if (auctionDto == null) + var myUser = await _workContext.GetCurrentCustomerAsync(); + if (auctionDto == null || myUser == null) { return new RedirectResult("/", false); } @@ -109,7 +111,7 @@ public class AuctionController(AuctionService auctionService, ILogger logger, IP model.LicitStep = nextStep; model.BasePrice = basePrice; model.CurrentPrice = currentPrice; - + model.UserCustomerId = myUser.Id; return View("~/Plugins/Misc.AuctionPlugin/Views/LiveScreen.cshtml", model); diff --git a/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs b/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs index 1d26f5a..7f5d876 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Models/LiveScreenViewModel.cs @@ -25,6 +25,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models public decimal LicitStep { get; set; } public decimal? CurrentPrice { get; set; } + public int UserCustomerId { get; set; } diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/LiveScreen.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/LiveScreen.cshtml index 82b8def..c935ce0 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Views/LiveScreen.cshtml +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/LiveScreen.cshtml @@ -132,7 +132,7 @@ var liveScreenPageViewModel = @Html.Raw(Json.Serialize(Model)); console.log("ViewModel:", liveScreenPageViewModel); - + let myUserId = liveScreenPageViewModel.UserCustomerId; // Extract and preprocess table data var tableData = liveScreenPageViewModel.CurrentProductToAuction.AuctionBidDtos .slice(0, 6) // Get the first 6 elements @@ -186,6 +186,10 @@ let auctionDto = data.auctionDto; let productToAuction = auctionDto.productToAuctionDtos[0]; + var liveScreenPageViewModel = @Html.Raw(Json.Serialize(Model)); + console.log("ViewModel:", liveScreenPageViewModel); + let myUserId = liveScreenPageViewModel.UserCustomerId; + var liveScreenLicitStep = document.getElementById("liveScreenLicitStep"); if(liveScreenLicitStep) { liveScreenLicitStep.textContent = data.nextStepAmount; @@ -194,6 +198,12 @@ if (liveScreenCurrentPrice) { liveScreenCurrentPrice.textContent= HUFFormatter.format(productToAuction.currentPrice); } + if (myUserId != productToAuction.winnerCustomerId) { + //ding + console.log(myUserId + ", " + productToAuction.winnerCustomerId); + var audio = new Audio('../../Plugins/Misc.AuctionPlugin/Content/ding.mp3'); + audio.play(); + } console.log(productToAuction); var table = document.getElementById("bidHistoryTable"); var row = table.insertRow(1); diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml index 7d27c94..dba2077 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml @@ -58,7 +58,9 @@
- #@(Model.AuctionDto.ProductToAuctionDtos.FirstOrDefault().SortIndex) +
#@(Model.AuctionDto.ProductToAuctionDtos.FirstOrDefault().SortIndex)
+ +

@title