ProductToAuctionStatusNotification; improvements, fixes, etc..
This commit is contained in:
parent
25a9b8723a
commit
acc9496490
|
|
@ -5,6 +5,7 @@ using Nop.Core.Events;
|
||||||
using Nop.Data;
|
using Nop.Data;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Hubs;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
||||||
|
|
||||||
|
|
@ -16,7 +17,8 @@ public class ProductToAuctionDbTable : MgDbTableBase<ProductToAuctionMapping>
|
||||||
|
|
||||||
private static bool HasActiveAuctionStatus(AuctionStatus auctionStatus)
|
private static bool HasActiveAuctionStatus(AuctionStatus auctionStatus)
|
||||||
{
|
{
|
||||||
return auctionStatus == AuctionStatus.Active;
|
//TODO: erre a problémára kitalálni valamit! - J.
|
||||||
|
return auctionStatus == AuctionStatus.Active || auctionStatus == AuctionStatus.FirstWarning || auctionStatus == AuctionStatus.SecondWarning;
|
||||||
//return auctionStatus.HasFlag(AuctionStatus.Active) || auctionStatus.HasFlag(AuctionStatus.FirstWarning) || auctionStatus.HasFlag(AuctionStatus.SecondWarning);
|
//return auctionStatus.HasFlag(AuctionStatus.Active) || auctionStatus.HasFlag(AuctionStatus.FirstWarning) || auctionStatus.HasFlag(AuctionStatus.SecondWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -27,11 +29,13 @@ public class ProductToAuctionDbTable : MgDbTableBase<ProductToAuctionMapping>
|
||||||
|
|
||||||
public IQueryable<ProductToAuctionMapping> GetByProductId(int productId, bool activeProductOnly = false)
|
public IQueryable<ProductToAuctionMapping> GetByProductId(int productId, bool activeProductOnly = false)
|
||||||
{
|
{
|
||||||
return Table.Where(x => x.ProductId == productId && (!activeProductOnly || x.AuctionStatus == AuctionStatus.Active/*HasActiveAuctionStatus(x.AuctionStatus)*/));
|
return Table.Where(x => x.ProductId == productId &&
|
||||||
|
(!activeProductOnly || x.AuctionStatus == AuctionStatus.Active || x.AuctionStatus == AuctionStatus.FirstWarning || x.AuctionStatus == AuctionStatus.SecondWarning/*HasActiveAuctionStatus(x.AuctionStatus)*/));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueryable<ProductToAuctionMapping> GetProductToAuctionsByAuctionId(int auctionId, bool activeProductOnly = false)
|
public IQueryable<ProductToAuctionMapping> GetProductToAuctionsByAuctionId(int auctionId, bool activeProductOnly = false)
|
||||||
{
|
{
|
||||||
return Table.Where(x => x.AuctionId == auctionId && (!activeProductOnly || x.AuctionStatus == AuctionStatus.Active/*HasActiveAuctionStatus(x.AuctionStatus)*/));
|
return Table.Where(x => x.AuctionId == auctionId &&
|
||||||
|
(!activeProductOnly || x.AuctionStatus == AuctionStatus.Active || x.AuctionStatus == AuctionStatus.FirstWarning || x.AuctionStatus == AuctionStatus.SecondWarning/*HasActiveAuctionStatus(x.AuctionStatus)*/));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
||||||
public abstract class AuctionNotificationBase
|
public abstract class AuctionNotificationBase
|
||||||
{
|
{
|
||||||
public AuctionDto AuctionDto { get; set; }
|
public AuctionDto AuctionDto { get; set; }
|
||||||
|
public string ToasterMessage { get; set; }
|
||||||
|
|
||||||
protected AuctionNotificationBase(){}
|
protected AuctionNotificationBase(){}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
|
||||||
|
|
||||||
public class AuctionProductStatusNotification : AuctionNotificationBase
|
|
||||||
{
|
|
||||||
public AuctionProductStatusNotification() { }
|
|
||||||
public AuctionProductStatusNotification(AuctionDto auctionDto):base(auctionDto) { }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
||||||
|
|
||||||
|
public class ProductToAuctionStatusNotification : AuctionNotificationBase
|
||||||
|
{
|
||||||
|
public ProductToAuctionStatusNotification() { }
|
||||||
|
public ProductToAuctionStatusNotification(AuctionDto auctionDto):base(auctionDto) { }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -42,11 +42,11 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: A MessageWrapper-ben kéne küldözgetni a UserId (CustomerId-t) - J.
|
//TODO: A MessageWrapper-ben kéne küldözgetni a UserId (CustomerId-t) - J.
|
||||||
//if (message.UserId != (await _workContext.GetCurrentCustomerAsync()).Id)
|
if (message.SenderId <= 0 || message.SenderId != (await _workContext.GetCurrentCustomerAsync()).Id)
|
||||||
//{
|
{
|
||||||
// _logger.Error($"SignalRMessageHandler.HandleMessage(); message.UserId != (await _workContext.GetCurrentCustomerAsync()).Id");
|
_logger.Error($"SignalRMessageHandler.HandleMessage(); message.SenderId <= 0 || message.SenderId != (await _workContext.GetCurrentCustomerAsync()).Id");
|
||||||
// return;
|
return;
|
||||||
//}
|
}
|
||||||
|
|
||||||
//TODO: lock-olni! - J.
|
//TODO: lock-olni! - J.
|
||||||
switch (message.MessageType)
|
switch (message.MessageType)
|
||||||
|
|
@ -98,10 +98,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
switch (auctionProductStatusRequest.AuctionStatus)
|
switch (auctionProductStatusRequest.AuctionStatus)
|
||||||
{
|
{
|
||||||
case AuctionStatus.FirstWarning:
|
case AuctionStatus.FirstWarning:
|
||||||
productToAuction.AuctionStatus = AuctionStatus.Active | AuctionStatus.FirstWarning;
|
productToAuction.AuctionStatus = AuctionStatus.FirstWarning; //AuctionStatus.Active | AuctionStatus.FirstWarning;
|
||||||
break;
|
break;
|
||||||
case AuctionStatus.SecondWarning:
|
case AuctionStatus.SecondWarning:
|
||||||
productToAuction.AuctionStatus = AuctionStatus.Active | AuctionStatus.SecondWarning;
|
productToAuction.AuctionStatus = AuctionStatus.SecondWarning; //AuctionStatus.Active | AuctionStatus.SecondWarning;
|
||||||
break;
|
break;
|
||||||
case AuctionStatus.None:
|
case AuctionStatus.None:
|
||||||
case AuctionStatus.Active:
|
case AuctionStatus.Active:
|
||||||
|
|
@ -113,10 +113,22 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
}
|
}
|
||||||
|
|
||||||
await _auctionService.UpdateProductToAuctionMappingAsync(productToAuction);
|
await _auctionService.UpdateProductToAuctionMappingAsync(productToAuction);
|
||||||
|
|
||||||
|
var bid = new MessageWrapper
|
||||||
|
{
|
||||||
|
MessageType = nameof(ProductToAuctionStatusNotification),
|
||||||
|
SenderId = senderId,
|
||||||
|
Data = new ProductToAuctionStatusNotification(await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(productToAuction.Id, true))
|
||||||
|
{
|
||||||
|
ToasterMessage = string.Empty, //TODO: - J.
|
||||||
|
}.ToJson()
|
||||||
|
};
|
||||||
|
|
||||||
|
await _hubContext.Clients.All.SendAsync("send", bid.ToJson());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error($"Error {ex.Message}");
|
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); Error {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -188,11 +200,12 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
{
|
{
|
||||||
MessageType = "bidNotification",
|
MessageType = "bidNotification",
|
||||||
SenderId = senderId,
|
SenderId = senderId,
|
||||||
Data = new BidNotificationMessage(await _auctionService.GetAuctionDtoWithProductByIdAsync(auction.Id, activeProductAuction.ProductId, true))
|
Data = new BidNotificationMessage(await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(activeProductAuction.Id, true))
|
||||||
{
|
{
|
||||||
ProductName = auctionBid.ProductId.ToString(),
|
ProductName = auctionBid.ProductId.ToString(),
|
||||||
BidPrice = auctionBid.BidPrice.ToString(CultureInfo.InvariantCulture),
|
BidPrice = auctionBid.BidPrice.ToString(CultureInfo.InvariantCulture),
|
||||||
NextStepAmount = "50000"
|
NextStepAmount = "50000",
|
||||||
|
ToasterMessage = string.Empty, //TODO: - J.
|
||||||
}.ToJson()
|
}.ToJson()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -231,8 +231,8 @@ public class AuctionService : IAuctionService
|
||||||
ProductId = productId,
|
ProductId = productId,
|
||||||
StartingPrice = startingPrice,
|
StartingPrice = startingPrice,
|
||||||
BidPrice = bidPrice,
|
BidPrice = bidPrice,
|
||||||
ProductAmount = 0,
|
ProductAmount = 1,
|
||||||
AuctionStatus = AuctionStatus.Active, //TODO: Ez miért Active alapból? - J.
|
AuctionStatus = AuctionStatus.None,
|
||||||
AuctionId = auctionId
|
AuctionId = auctionId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue