From 0123eb0525c4a344cd2e4512df2bda3ce69756d9 Mon Sep 17 00:00:00 2001 From: Loretta Date: Thu, 28 Aug 2025 13:27:14 +0200 Subject: [PATCH] ??? --- .../AuctionPluginAdminController.cs | 3 +- .../LiveAnnouncementViewComponent.cs | 54 ++----------------- .../Services/AuctionService.cs | 4 +- .../Services/IAuctionService.cs | 1 + 4 files changed, 8 insertions(+), 54 deletions(-) diff --git a/Nop.Plugin.Misc.AuctionPlugin/Areas/Admin/Controllers/AuctionPluginAdminController.cs b/Nop.Plugin.Misc.AuctionPlugin/Areas/Admin/Controllers/AuctionPluginAdminController.cs index 5e01329..faec1d5 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Areas/Admin/Controllers/AuctionPluginAdminController.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Areas/Admin/Controllers/AuctionPluginAdminController.cs @@ -13,6 +13,7 @@ using Nop.Plugin.Misc.AuctionPlugin.Services; using Nop.Web.Framework.Models.DataTables; using Nop.Plugin.Misc.AuctionPlugin.Models; using AyCode.Core.Extensions; +using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities.Interfaces; namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers; @@ -180,7 +181,7 @@ public class AuctionPluginAdminController : BasePluginController var result = await _auctionService.AssignProductToAuctionAsync(Convert.ToInt32(model.ProductId), Convert.ToDecimal(model.StartingPrice), Convert.ToDecimal(model.BidPrice), Convert.ToInt32(model.AuctionId), model.SortIndex); - + return result != null ? Ok("Baaaazdmeeeeeeeeg") : StatusCode(500, "Error assigning product to auction."); } diff --git a/Nop.Plugin.Misc.AuctionPlugin/Components/LiveAnnouncementViewComponent.cs b/Nop.Plugin.Misc.AuctionPlugin/Components/LiveAnnouncementViewComponent.cs index e187efc..373448b 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Components/LiveAnnouncementViewComponent.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Components/LiveAnnouncementViewComponent.cs @@ -26,64 +26,15 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Components { var customer = await workContext.GetCurrentCustomerAsync(); var currency = await workContext.GetWorkingCurrencyAsync(); - await logger.InformationAsync($"LiveAnnouncementViewComponent.InvokeAsync(); Before lock; widgetZone: {widgetZone}", null, customer); - //using (await lockService.SemaphoreSlim.UseWaitAsync()) - //{ - // await logger.InformationAsync($"LiveAnnouncementViewComponent.InvokeAsync(); Enter lock; widgetZone: {widgetZone}", null, customer); - - // await Task.Delay(1000); - - // var auctions = await auctionService.GetAllCurrentAutoOpenAndClosedAuctionsAsync(); - // if (auctions.Count > 0) - // { - // await logger.InformationAsync($"LiveAnnouncementViewComponent.InvokeAsync(); auctions.Count > 0; count: {auctions.Count}; names: {string.Join("; ", auctions.Select(x => x.AuctionName))}"); - - // var statusChangedMessageWrapper = new MessageWrapper - // { - // MessageType = nameof(ProductToAuctionStatusNotification), - // SenderId = 0, - // ResponseType = ResponseType.ToAllClients - // }; - - // foreach (var auction in auctions) - // { - // auction.Closed = false; - // await auctionService.UpdateAuctionAsync(auction); - - // var auctionDto = new AuctionDto(auction); - // var productToAuctions = (await auctionService.GetProductToAuctionsByAuctionIdAsync(auction.Id, false)).Where(x => x.AuctionStatus == AuctionStatus.None).ToList(); - - // foreach (var productToAuction in productToAuctions) - // { - // productToAuction.AuctionStatus = AuctionStatus.Active; - // auctionDto.ProductToAuctionDtos.Add(new ProductToAuctionDto(productToAuction)); - - // ////TEMPOPRARY - J. - // //statusChangedMessageWrapper.Data = new ProductToAuctionStatusNotification(auctionDto, 0, $"Az aukciót megnyitottuk: {auction.AuctionName}").ToJson(); - // //await _auctionHubContext.Clients.All.SendAsync("send", statusChangedMessageWrapper.ToJson()); - // ////TEMPOPRARY - J. - // } - - // await auctionService.UpdateProductToAuctionMappingAsync(productToAuctions); - - // statusChangedMessageWrapper.Data = new ProductToAuctionStatusNotification(auctionDto, 0, $"Az aukciót megnyitottuk: {auction.AuctionName}").ToJson(); - // await auctionHubContext.Clients.All.SendAsync("send", statusChangedMessageWrapper.ToJson()); - // } - // } - - // await logger.InformationAsync($"LiveAnnouncementViewComponent.InvokeAsync(); Exit lock; widgetZone: {widgetZone}", null, customer); - //} - - await logger.InformationAsync($"SignalR Widget called customer: {customer.Email}"); + await logger.InformationAsync($"LiveAnnouncementViewComponent.InvokeAsync(); widgetZone: {widgetZone}, customer: {customer.Email}", null, customer); if (!await widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer)) return Content(string.Empty); - await logger.InformationAsync("SignalR Widget: widget active"); + await logger.InformationAsync("LiveAnnouncementViewComponent.InvokeAsync(); SignalR Widget: widget active"); if (!widgetZone.Equals(PublicWidgetZones.BodyStartHtmlTagAfter)) - return Content(string.Empty); LiveAnnouncementViewModel myModel = new LiveAnnouncementViewModel(); @@ -93,6 +44,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Components myModel.WorkingCurrency = currency; myModel.IsAdmin = await customerService.IsAdminAsync(customer); myModel.IsGuest = await customerService.IsGuestAsync(customer); + return View("~/Plugins/Misc.AuctionPlugin/Views/LiveAnnouncement.cshtml", myModel); } } diff --git a/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs b/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs index 9da28f1..7267e9f 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs @@ -111,14 +111,14 @@ public class AuctionService( var productToAuction = await GetProductToAuctionMappingByIdAsync(productToAuctionId); if (productToAuction == null) { - logger.Error($"AuctionHub.GetAndUpdateProductToAuctionStatusIfValidAsync(); (productToAuction == null)", null, customer); + logger.Error($"AuctionHub.GetAndUpdateProductToAuctionStatusIfValidAsync(); (productToAuction == null); productToAuctionId: {productToAuctionId}", null, customer); return (null, null, ResponseType.None); } var auction = await GetAuctionByIdAsync(productToAuction.AuctionId); if (auction == null || auction.Closed) { - logger.Error($"AuctionHub.GetAndUpdateProductToAuctionStatusIfValidAsync(); (auction == null || auction.Closed); Closed: {auction?.Closed}", null, customer); + logger.Error($"AuctionHub.GetAndUpdateProductToAuctionStatusIfValidAsync(); (auction == null || auction.Closed); Closed: {auction?.Closed}; auctionId: {productToAuction.AuctionId}", null, customer); return (null, null, ResponseType.None); } diff --git a/Nop.Plugin.Misc.AuctionPlugin/Services/IAuctionService.cs b/Nop.Plugin.Misc.AuctionPlugin/Services/IAuctionService.cs index 9a85d8a..db6b23c 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Services/IAuctionService.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Services/IAuctionService.cs @@ -69,6 +69,7 @@ public interface IAuctionService Task GetAuctionBidDtoByIdAsync(int auctionBidId); Task AssignProductToAuctionAsync(int productId, decimal startingPrice, decimal bidPrice, int auctionId, int sortIndex); + Task> GetProductToAuctionsByProductIdAsync(int productId); Task> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId, bool activeProductOnly);