imrpovements, fixes
This commit is contained in:
parent
85b520d6c3
commit
f8bc35cf05
|
|
@ -9,7 +9,8 @@
|
||||||
SecondWarning: 4,
|
SecondWarning: 4,
|
||||||
Pause: 8,
|
Pause: 8,
|
||||||
Sold: 16,
|
Sold: 16,
|
||||||
NotSold: 32
|
NotSold: 32,
|
||||||
|
TEST: 64
|
||||||
});
|
});
|
||||||
|
|
||||||
// HUF Formatter
|
// HUF Formatter
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer.Interfaces;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using System;
|
using System;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
using Nop.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
||||||
|
|
@ -13,6 +14,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
||||||
public class AuctionDbContext : MgDbContextBase, IAuctionDbSet<AuctionDbTable>, IProductToAuctionDbSet<ProductToAuctionDbTable>, IAuctionBidDbSet<AuctionBidDbTable>
|
public class AuctionDbContext : MgDbContextBase, IAuctionDbSet<AuctionDbTable>, IProductToAuctionDbSet<ProductToAuctionDbTable>, IAuctionBidDbSet<AuctionBidDbTable>
|
||||||
{
|
{
|
||||||
private readonly IProductService _productService;
|
private readonly IProductService _productService;
|
||||||
|
private readonly IStaticCacheManager _staticCacheManager;
|
||||||
|
|
||||||
public AuctionDbTable Auctions { get; set; }
|
public AuctionDbTable Auctions { get; set; }
|
||||||
public ProductToAuctionDbTable ProductToAuctions { get; set; }
|
public ProductToAuctionDbTable ProductToAuctions { get; set; }
|
||||||
|
|
@ -23,9 +25,10 @@ public class AuctionDbContext : MgDbContextBase, IAuctionDbSet<AuctionDbTable>,
|
||||||
//public IRepository<AuctionBid> AuctionBids2 { get; set; }
|
//public IRepository<AuctionBid> AuctionBids2 { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public AuctionDbContext(INopDataProvider dataProvider, AuctionDbTable auctionDbTable, ProductToAuctionDbTable productToAuctionDbTable, AuctionBidDbTable auctionBidDbTable, IProductService productService, ILogger logger) : base(dataProvider, logger)
|
public AuctionDbContext(INopDataProvider dataProvider, AuctionDbTable auctionDbTable, ProductToAuctionDbTable productToAuctionDbTable, AuctionBidDbTable auctionBidDbTable, IProductService productService, IStaticCacheManager staticCacheManager, ILogger logger) : base(dataProvider, logger)
|
||||||
{
|
{
|
||||||
_productService = productService;
|
_productService = productService;
|
||||||
|
_staticCacheManager = staticCacheManager;
|
||||||
|
|
||||||
Auctions = auctionDbTable;
|
Auctions = auctionDbTable;
|
||||||
ProductToAuctions = productToAuctionDbTable;
|
ProductToAuctions = productToAuctionDbTable;
|
||||||
|
|
@ -84,9 +87,16 @@ public class AuctionDbContext : MgDbContextBase, IAuctionDbSet<AuctionDbTable>,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (basePrice <= 0) basePrice = product.Price;
|
if (basePrice <= 0) basePrice = product.Price;
|
||||||
else product.Price = basePrice;
|
else
|
||||||
|
{
|
||||||
|
product.Price = basePrice;
|
||||||
|
await _productService.UpdateProductAsync(product);
|
||||||
|
}
|
||||||
|
|
||||||
await ProductToAuctions.ResetAsync(productToAuction, basePrice);
|
await ProductToAuctions.ResetAsync(productToAuction, basePrice);
|
||||||
await AuctionBids.DeleteAllByProductToAuctionIdAsync(productToAuction.Id);
|
await AuctionBids.DeleteAllByProductToAuctionIdAsync(productToAuction.Id);
|
||||||
|
|
||||||
|
await _staticCacheManager.ClearAsync();
|
||||||
|
//await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -13,6 +13,8 @@ using Nop.Core.Domain.Customers;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
using Nop.Services.Customers;
|
using Nop.Services.Customers;
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using Mango.Nop.Core.Repositories;
|
||||||
|
using Nop.Core.Caching;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
{
|
{
|
||||||
|
|
@ -91,7 +93,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
{
|
{
|
||||||
if (revertAuctionBidRequest == null)
|
if (revertAuctionBidRequest == null)
|
||||||
{
|
{
|
||||||
logger.Error($"SignalRMessageHandler.HanldeRevertAuctionBidRequest(); auctionProductStatusRequest == null", null, customer);
|
logger.Error($"SignalRMessageHandler.HandleRevertAuctionBidRequest(); auctionProductStatusRequest == null", null, customer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +102,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
var productToAuction = (await auctionService.GetProductToAuctionMappingByIdAsync(revertAuctionBidRequest.ProductToAuctionId));
|
var productToAuction = (await auctionService.GetProductToAuctionMappingByIdAsync(revertAuctionBidRequest.ProductToAuctionId));
|
||||||
if (productToAuction is not { AuctionStatus: AuctionStatus.Pause })
|
if (productToAuction is not { AuctionStatus: AuctionStatus.Pause })
|
||||||
{
|
{
|
||||||
logger.Warning($"SignalRMessageHandler.HandleBidRequest(); (productToAuction is not {{ AuctionStatus: AuctionStatus.Pause }}); AuctionStatus: {productToAuction?.AuctionStatus}", null, customer);
|
logger.Warning($"SignalRMessageHandler.HandleRevertAuctionBidRequest(); (productToAuction is not {{ AuctionStatus: AuctionStatus.Pause }}); AuctionStatus: {productToAuction?.AuctionStatus}", null, customer);
|
||||||
return; //TODO: - J.
|
return; //TODO: - J.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,6 +113,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
if (revertLastBid == null)
|
if (revertLastBid == null)
|
||||||
{
|
{
|
||||||
//TODO: NA ILYENKOR VAN A CUMI... - J.
|
//TODO: NA ILYENKOR VAN A CUMI... - J.
|
||||||
|
logger.Warning($"SignalRMessageHandler.HandleRevertAuctionBidRequest(); revertLastBid == null", null, customer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +122,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.Error($"SignalRMessageHandler.HanldeRevertAuctionBidRequest(); Exception: {ex.Message}", ex, customer);
|
logger.Error($"SignalRMessageHandler.HandleRevertAuctionBidRequest(); Exception: {ex.Message}", ex, customer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,9 +237,9 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
}
|
}
|
||||||
|
|
||||||
var activeProductAuction = (await auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(bidRequestMessage.AuctionId, bidRequestMessage.ProductId, true)).FirstOrDefault();
|
var activeProductAuction = (await auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(bidRequestMessage.AuctionId, bidRequestMessage.ProductId, true)).FirstOrDefault();
|
||||||
if (activeProductAuction is not { IsActiveItem: true } || activeProductAuction.WinnerCustomerId == customer.Id)
|
if (activeProductAuction is not { IsActiveItem: true } || (activeProductAuction.WinnerCustomerId == customer.Id && !await customerService.IsAdminAsync(customer)))
|
||||||
{
|
{
|
||||||
logger.Warning($"SignalRMessageHandler.HandleBidRequest(); (activeProductAuction is not {{ IsActiveItem: true }}); AuctionStatus: {activeProductAuction?.AuctionStatus};", null, customer);
|
logger.Warning($"SignalRMessageHandler.HandleBidRequest(); (activeProductAuction is not {{ IsActiveItem: true }} || activeProductAuction.WinnerCustomerId == customer.Id && !await customerService.IsAdminAsync(customer)); AuctionStatus: {activeProductAuction?.AuctionStatus}; WinnerCustomerId: {activeProductAuction?.WinnerCustomerId}", null, customer);
|
||||||
return; //TODO: - J.
|
return; //TODO: - J.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,14 +249,13 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
var auctionBid = bidRequestMessage.CreateMainEntity();
|
var auctionBid = bidRequestMessage.CreateMainEntity();
|
||||||
auctionBid.ProductAuctionMappingId = activeProductAuction.Id;
|
auctionBid.ProductAuctionMappingId = activeProductAuction.Id;
|
||||||
|
|
||||||
//TODO: validate the bidprice amount
|
//TODO: Validálni, h a bejövő BidPrice valóban a következő licit lépcső! - J.
|
||||||
if (product.Price >= auctionBid.BidPrice || activeProductAuction.CurrentPrice >= auctionBid.BidPrice)
|
if (product.Price >= auctionBid.BidPrice || activeProductAuction.CurrentPrice >= auctionBid.BidPrice)
|
||||||
{
|
{
|
||||||
logger.Warning($"SignalRMessageHandler.HandleBidRequest(); (product.Price >= bidRequestMessage.BidPrice || activeProductAuction.CurrentPrice >= auctionBid.BidPrice); productPrice: {product.Price}; bidRequestPrice: {auctionBid.BidPrice}; activeProductAuctionPrice: {activeProductAuction.CurrentPrice}", null, customer);
|
logger.Warning($"SignalRMessageHandler.HandleBidRequest(); (product.Price >= bidRequestMessage.BidPrice || activeProductAuction.CurrentPrice >= auctionBid.BidPrice); productPrice: {product.Price}; bidRequestPrice: {auctionBid.BidPrice}; activeProductAuctionPrice: {activeProductAuction.CurrentPrice}", null, customer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//save bid
|
|
||||||
await auctionService.InsertBidAsync(auctionBid);
|
await auctionService.InsertBidAsync(auctionBid);
|
||||||
|
|
||||||
activeProductAuction.AuctionStatus = AuctionStatus.Active;
|
activeProductAuction.AuctionStatus = AuctionStatus.Active;
|
||||||
|
|
@ -316,13 +318,13 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
switch (oldStatus)
|
switch (oldStatus)
|
||||||
{
|
{
|
||||||
case AuctionStatus.None:
|
case AuctionStatus.None:
|
||||||
return newStatus == AuctionStatus.Active;
|
return newStatus is AuctionStatus.Active or AuctionStatus.Pause;
|
||||||
case AuctionStatus.Active:
|
case AuctionStatus.Active:
|
||||||
return newStatus is AuctionStatus.None or AuctionStatus.FirstWarning or AuctionStatus.Pause;
|
return newStatus is AuctionStatus.FirstWarning or AuctionStatus.Pause;
|
||||||
case AuctionStatus.FirstWarning:
|
case AuctionStatus.FirstWarning:
|
||||||
return newStatus is AuctionStatus.None or AuctionStatus.SecondWarning or AuctionStatus.Pause;
|
return newStatus is AuctionStatus.SecondWarning or AuctionStatus.Pause;
|
||||||
case AuctionStatus.SecondWarning:
|
case AuctionStatus.SecondWarning:
|
||||||
return newStatus is AuctionStatus.None or AuctionStatus.Sold or AuctionStatus.Pause;
|
return newStatus is AuctionStatus.Sold or AuctionStatus.Pause;
|
||||||
case AuctionStatus.Pause:
|
case AuctionStatus.Pause:
|
||||||
return newStatus is AuctionStatus.None or AuctionStatus.Active;
|
return newStatus is AuctionStatus.None or AuctionStatus.Active;
|
||||||
case AuctionStatus.Sold:
|
case AuctionStatus.Sold:
|
||||||
|
|
|
||||||
|
|
@ -21,25 +21,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AuctionService : IAuctionService
|
public class AuctionService : IAuctionService
|
||||||
{
|
{
|
||||||
#region Constants
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Cache key for pickup points
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// {0} : current store ID
|
|
||||||
/// </remarks>
|
|
||||||
private readonly CacheKey _auctionAllKey = new("Nop.auction.all-{0}", AUCTION_PATTERN_KEY);
|
|
||||||
private const string AUCTION_PATTERN_KEY = "Nop.auction.";
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
private readonly AuctionDbContext _ctx;
|
private readonly AuctionDbContext _ctx;
|
||||||
private readonly IProductService _productService;
|
private readonly IProductService _productService;
|
||||||
private readonly IShortTermCacheManager _shortTermCacheManager;
|
|
||||||
private readonly IStaticCacheManager _staticCacheManager;
|
|
||||||
private readonly IWorkContext _workContext;
|
private readonly IWorkContext _workContext;
|
||||||
private readonly IOrderProcessingService _orderProcessingService;
|
private readonly IOrderProcessingService _orderProcessingService;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
@ -53,27 +38,13 @@ public class AuctionService : IAuctionService
|
||||||
/// <param name="ctx"></param>
|
/// <param name="ctx"></param>
|
||||||
/// <param name="shortTermCacheManager">Short term cache manager</param>
|
/// <param name="shortTermCacheManager">Short term cache manager</param>
|
||||||
/// <param name="staticCacheManager">Cache manager</param>
|
/// <param name="staticCacheManager">Cache manager</param>
|
||||||
|
/// <param name="productService"></param>
|
||||||
/// <param name="workContext"></param>
|
/// <param name="workContext"></param>
|
||||||
/// <param name="logger"></param>
|
/// <param name="logger"></param>
|
||||||
public AuctionService(
|
public AuctionService(AuctionDbContext ctx, IProductService productService, IWorkContext workContext, IOrderProcessingService orderProcessingService, ILogger logger)
|
||||||
AuctionDbContext ctx,
|
|
||||||
IProductService productService,
|
|
||||||
|
|
||||||
//IRepository<Auction> auctionRepository,
|
|
||||||
//IRepository<ProductToAuctionMapping> productToAuctionRepository,
|
|
||||||
IShortTermCacheManager shortTermCacheManager,
|
|
||||||
IStaticCacheManager staticCacheManager,
|
|
||||||
IWorkContext workContext,
|
|
||||||
IOrderProcessingService orderProcessingService,
|
|
||||||
ILogger logger)
|
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
_productService = productService;
|
_productService = productService;
|
||||||
//_customerBidRepository = customerBidRepository;
|
|
||||||
//_auctionRepository = auctionRepository;
|
|
||||||
//_productToAuctionRepository = productToAuctionRepository;
|
|
||||||
_shortTermCacheManager = shortTermCacheManager;
|
|
||||||
_staticCacheManager = staticCacheManager;
|
|
||||||
_workContext = workContext;
|
_workContext = workContext;
|
||||||
_orderProcessingService = orderProcessingService;
|
_orderProcessingService = orderProcessingService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
@ -195,7 +166,6 @@ public class AuctionService : IAuctionService
|
||||||
if (await ValidateAuctionBid(auctionBid))
|
if (await ValidateAuctionBid(auctionBid))
|
||||||
{
|
{
|
||||||
await _ctx.AuctionBids.InsertAsync(auctionBid, false);
|
await _ctx.AuctionBids.InsertAsync(auctionBid, false);
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,7 +174,6 @@ public class AuctionService : IAuctionService
|
||||||
if (await ValidateAuctionBid(auctionBid))
|
if (await ValidateAuctionBid(auctionBid))
|
||||||
{
|
{
|
||||||
await _ctx.AuctionBids.UpdateAsync(auctionBid, false);
|
await _ctx.AuctionBids.UpdateAsync(auctionBid, false);
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,7 +185,6 @@ public class AuctionService : IAuctionService
|
||||||
public async Task DeleteBidAsync(AuctionBid pickupPoint)
|
public async Task DeleteBidAsync(AuctionBid pickupPoint)
|
||||||
{
|
{
|
||||||
await _ctx.AuctionBids.DeleteAsync(pickupPoint, false);
|
await _ctx.AuctionBids.DeleteAsync(pickupPoint, false);
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task CreateOrderForWinner(ProductToAuctionMapping auctionItem)
|
public async Task CreateOrderForWinner(ProductToAuctionMapping auctionItem)
|
||||||
|
|
@ -230,13 +198,11 @@ public class AuctionService : IAuctionService
|
||||||
public async Task InsertAuctionAsync(Auction auction)
|
public async Task InsertAuctionAsync(Auction auction)
|
||||||
{
|
{
|
||||||
await _ctx.Auctions.InsertAsync(auction, false);
|
await _ctx.Auctions.InsertAsync(auction, false);
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAuctionAsync(Auction auction)
|
public async Task UpdateAuctionAsync(Auction auction)
|
||||||
{
|
{
|
||||||
await _ctx.Auctions.UpdateAsync(auction);
|
await _ctx.Auctions.UpdateAsync(auction);
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IList<Auction>> GetAllAuctionsAsync()
|
public async Task<IList<Auction>> GetAllAuctionsAsync()
|
||||||
|
|
@ -368,7 +334,6 @@ public class AuctionService : IAuctionService
|
||||||
public async Task UpdateProductToAuctionMappingAsync(ProductToAuctionMapping productToAuctionMapping)
|
public async Task UpdateProductToAuctionMappingAsync(ProductToAuctionMapping productToAuctionMapping)
|
||||||
{
|
{
|
||||||
await _ctx.ProductToAuctions.UpdateAsync(productToAuctionMapping);
|
await _ctx.ProductToAuctions.UpdateAsync(productToAuctionMapping);
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Dtos
|
#endregion Dtos
|
||||||
|
|
|
||||||
|
|
@ -118,10 +118,12 @@
|
||||||
|
|
||||||
document.getElementById("signalRBidButton").disabled = true;
|
document.getElementById("signalRBidButton").disabled = true;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (!bidBoxPageViewModel) {
|
if (!bidBoxPageViewModel) {
|
||||||
console.log("we need viewmodel data");
|
console.log("we need viewmodel data");
|
||||||
bidBoxPageViewModel = @Html.Raw(Json.Serialize(Model));
|
bidBoxPageViewModel = @Html.Raw(Json.Serialize(Model));
|
||||||
}
|
}
|
||||||
|
|
||||||
var bidMessage = {
|
var bidMessage = {
|
||||||
ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
|
ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
|
||||||
AuctionId: bidBoxPageViewModel.AuctionId,
|
AuctionId: bidBoxPageViewModel.AuctionId,
|
||||||
|
|
@ -129,6 +131,7 @@
|
||||||
ProductId: bidBoxPageViewModel.ProductId,
|
ProductId: bidBoxPageViewModel.ProductId,
|
||||||
CustomerId: bidBoxPageViewModel.CustomerId
|
CustomerId: bidBoxPageViewModel.CustomerId
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = JSON.stringify(bidMessage);
|
var content = JSON.stringify(bidMessage);
|
||||||
console.log("WTF " + content);
|
console.log("WTF " + content);
|
||||||
sendMessageToServer("BidRequestMessage", bidBoxPageViewModel.CustomerId, content);
|
sendMessageToServer("BidRequestMessage", bidBoxPageViewModel.CustomerId, content);
|
||||||
|
|
@ -150,7 +153,7 @@
|
||||||
document.getElementById("signalRCloseItemButton").disabled = true;
|
document.getElementById("signalRCloseItemButton").disabled = true;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
sendAuctionStatusChange(AuctionStatus.Sold); //Itt SoldOut volt, átírtam Sold-ra! - J.
|
sendAuctionStatusChange(AuctionStatus.Sold);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
@ -186,11 +189,30 @@
|
||||||
document.getElementById("signalRRevertBidButton").disabled = true;
|
document.getElementById("signalRRevertBidButton").disabled = true;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
sendAuctionStatusChange(AuctionStatus.Revert);
|
if (!bidBoxPageViewModel) {
|
||||||
|
console.log("we need viewmodel data");
|
||||||
|
bidBoxPageViewModel = @Html.Raw(Json.Serialize(Model));
|
||||||
|
}
|
||||||
|
|
||||||
|
var revertMessage = {
|
||||||
|
ProductToAuctionId: bidBoxPageViewModel.ProductToAuctionId,
|
||||||
|
};
|
||||||
|
|
||||||
|
var content = JSON.stringify(revertMessage);
|
||||||
|
console.log("WTF " + content);
|
||||||
|
sendMessageToServer("RevertAuctionBidRequest", bidBoxPageViewModel.CustomerId, content);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
$("#signalRResetItemButton").on("click", function () {
|
||||||
|
|
||||||
|
document.getElementById("signalRResetItemButton").disabled = true;
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
sendAuctionStatusChange(AuctionStatus.None);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function sendAuctionStatusChange(auctionStatus) {
|
function sendAuctionStatusChange(auctionStatus) {
|
||||||
|
|
@ -231,7 +253,11 @@
|
||||||
console.log(data);
|
console.log(data);
|
||||||
var productAuctionMappingId = data.auctionDto.productToAuctionDtos[0].id;
|
var productAuctionMappingId = data.auctionDto.productToAuctionDtos[0].id;
|
||||||
console.log(productAuctionMappingId);
|
console.log(productAuctionMappingId);
|
||||||
|
|
||||||
|
//TODO: TESZT STATUS!!! - JTEST.
|
||||||
var status = data.auctionDto.productToAuctionDtos[0].auctionStatus;
|
var status = data.auctionDto.productToAuctionDtos[0].auctionStatus;
|
||||||
|
//var status = AuctionStatus.TEST;
|
||||||
|
|
||||||
//if (status == AuctionStatus.FirstWarning) {
|
//if (status == AuctionStatus.FirstWarning) {
|
||||||
setButtons(status);
|
setButtons(status);
|
||||||
//}
|
//}
|
||||||
|
|
@ -274,9 +300,13 @@
|
||||||
function handleAuctionUpdate(data) {
|
function handleAuctionUpdate(data) {
|
||||||
var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId);
|
var widgetPriceElement = document.getElementById("price-value-" + bidBoxPageViewModel.ProductId);
|
||||||
var productAuctionMappingId = data.auctionDto.productToAuctionDtos[0].id;
|
var productAuctionMappingId = data.auctionDto.productToAuctionDtos[0].id;
|
||||||
|
|
||||||
|
//TODO: TESZT STATUS!!! - JTEST.
|
||||||
var itemStatus = data.auctionDto.productToAuctionDtos[0].auctionStatus;
|
var itemStatus = data.auctionDto.productToAuctionDtos[0].auctionStatus;
|
||||||
|
//var itemStatus = AuctionStatus.TEST;
|
||||||
|
|
||||||
console.log("handle auction update called" + productAuctionMappingId);
|
console.log("handle auction update called" + productAuctionMappingId);
|
||||||
console.log("auction status:" + itemStatus)
|
console.log("auction status:" + itemStatus);
|
||||||
if (widgetPriceElement) {
|
if (widgetPriceElement) {
|
||||||
|
|
||||||
if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) {
|
if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) {
|
||||||
|
|
@ -376,6 +406,17 @@
|
||||||
signalRRevertBidButton: false,
|
signalRRevertBidButton: false,
|
||||||
signalRResetItemButton: false,
|
signalRResetItemButton: false,
|
||||||
},
|
},
|
||||||
|
[AuctionStatus.TEST]: {
|
||||||
|
signalRBidButton: false,
|
||||||
|
signalRFirstWarningButton: false,
|
||||||
|
signalRSecondWarningButton: false,
|
||||||
|
signalROpenItemButton: false,
|
||||||
|
signalRCloseItemButton: false,
|
||||||
|
signalRPauseItemButton: false,
|
||||||
|
signalRRevertBidButton: false,
|
||||||
|
signalRResetItemButton: false,
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get the states for the given auctionStatus
|
// Get the states for the given auctionStatus
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue