This commit is contained in:
Loretta 2025-08-28 13:27:14 +02:00
parent e6cfe35cc2
commit 0123eb0525
4 changed files with 8 additions and 54 deletions

View File

@ -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.");
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -69,6 +69,7 @@ public interface IAuctionService
Task<AuctionBidDto> GetAuctionBidDtoByIdAsync(int auctionBidId);
Task<ProductToAuctionMapping> AssignProductToAuctionAsync(int productId, decimal startingPrice, decimal bidPrice, int auctionId, int sortIndex);
Task<List<ProductToAuctionMapping>> GetProductToAuctionsByProductIdAsync(int productId);
Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId, bool activeProductOnly);