BidsCount; improvements, fixes, etc..
This commit is contained in:
parent
849c04c10b
commit
12d207e208
|
|
@ -18,6 +18,9 @@ public class AuctionBidDbTable : MgDbTableBase<AuctionBid>
|
|||
public IQueryable<AuctionBid> GetLastAuctionBidByProductToAuctionId(int productToAuctionId)
|
||||
=> GetByProductToAuctionId(productToAuctionId).OrderByDescending(x => x.Id);
|
||||
|
||||
public Task<int> GetBidsCountByProductToAuctionIdAsync(int productToAuctionId)
|
||||
=> Table.CountAsync(x => x.ProductAuctionMappingId == productToAuctionId);
|
||||
|
||||
public IQueryable<AuctionBid> GetByProductToAuctionId(int productToAuctionId)
|
||||
=> Table.Where(x => x.ProductAuctionMappingId == productToAuctionId);
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ public class AuctionDbContext : MgDbContextBase, IAuctionDbSet<AuctionDbTable>,
|
|||
public Task<AuctionBid> GetLastAuctionBidByProductToAuctionId(int productToAuctionId)
|
||||
=> AuctionBids.GetLastAuctionBidByProductToAuctionId(productToAuctionId).FirstOrDefaultAsync();
|
||||
|
||||
public Task<int> GetBidsCountByProductToAuctionIdAsync(int productToAuctionId)
|
||||
=> AuctionBids.GetBidsCountByProductToAuctionIdAsync(productToAuctionId);
|
||||
|
||||
|
||||
public Task<AuctionBid> RevertAuctionBidByProductToAuctionId(int productToAuctionId)
|
||||
=> AuctionBids.RevertByProductToAuctionIdAsync(productToAuctionId);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,17 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
|||
public abstract class AuctionNotificationBase
|
||||
{
|
||||
public AuctionDto AuctionDto { get; set; }
|
||||
|
||||
public string ToasterMessage { get; set; }
|
||||
public int BidsCount { get; set; }
|
||||
|
||||
protected AuctionNotificationBase(){}
|
||||
|
||||
protected AuctionNotificationBase(AuctionDto auctionDto)
|
||||
protected AuctionNotificationBase(AuctionDto auctionDto, int bidsCount, string toasterMessage)
|
||||
{
|
||||
AuctionDto = auctionDto;
|
||||
|
||||
BidsCount = bidsCount;
|
||||
ToasterMessage = toasterMessage;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,11 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
|||
|
||||
public class AuctionStatusNotification : AuctionNotificationBase
|
||||
{
|
||||
public AuctionStatusNotification() { }
|
||||
public AuctionStatusNotification(AuctionDto auctionDto):base(auctionDto) { }
|
||||
public AuctionStatusNotification()
|
||||
{
|
||||
}
|
||||
|
||||
public AuctionStatusNotification(AuctionDto auctionDto, int bidsCount, string toasterMessage) : base(auctionDto, bidsCount, toasterMessage)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -18,9 +18,13 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages
|
|||
public decimal CurrentPrice { get; set; }
|
||||
public decimal NextBidPrice { get; set; }
|
||||
public decimal NextStepAmount { get; set; }
|
||||
|
||||
public BidNotificationMessage() { }
|
||||
public BidNotificationMessage(AuctionDto auctionDto):base(auctionDto) { }
|
||||
}
|
||||
|
||||
public BidNotificationMessage()
|
||||
{
|
||||
}
|
||||
|
||||
public BidNotificationMessage(AuctionDto auctionDto, int bidsCount, string toasterMessage) : base(auctionDto, bidsCount, toasterMessage)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,11 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
|||
|
||||
public class ProductToAuctionStatusNotification : AuctionNotificationBase
|
||||
{
|
||||
public ProductToAuctionStatusNotification() { }
|
||||
public ProductToAuctionStatusNotification(AuctionDto auctionDto):base(auctionDto) { }
|
||||
public ProductToAuctionStatusNotification()
|
||||
{
|
||||
}
|
||||
|
||||
public ProductToAuctionStatusNotification(AuctionDto auctionDto, int bidsCount, string toasterMessage) : base(auctionDto, bidsCount, toasterMessage)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -199,14 +199,12 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
|||
await auctionService.UpdateProductToAuctionMappingAsync(productToAuction);
|
||||
}
|
||||
|
||||
var bidsCount = await auctionService.GetBidsCountByProductToAuctionIdAsync(productToAuction.Id);
|
||||
var productToauctionChangedNotification = new MessageWrapper
|
||||
{
|
||||
MessageType = nameof(ProductToAuctionStatusNotification),
|
||||
SenderId = customer.Id,
|
||||
Data = new ProductToAuctionStatusNotification(await auctionService.GetAuctionDtoByProductToAuctionIdAsync(productToAuction.Id, true))
|
||||
{
|
||||
ToasterMessage = "EMPTY", //TODO: - J.
|
||||
}.ToJson()
|
||||
Data = new ProductToAuctionStatusNotification(await auctionService.GetAuctionDtoByProductToAuctionIdAsync(productToAuction.Id, true), bidsCount, "EMPTY").ToJson()
|
||||
};
|
||||
|
||||
await hubContext.Clients.All.SendAsync("send", productToauctionChangedNotification.ToJson());
|
||||
|
|
@ -286,17 +284,17 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
|||
var stepAmount = GetStepAmount(productToAuction.CurrentPrice);
|
||||
var nextBidPrice = GetNextBidPrice(productToAuction.CurrentPrice, stepAmount);
|
||||
|
||||
var bidsCount = await auctionService.GetBidsCountByProductToAuctionIdAsync(productToAuction.Id);
|
||||
var bidMessage = new MessageWrapper
|
||||
{
|
||||
MessageType = "bidNotification",
|
||||
SenderId = customerId,
|
||||
Data = new BidNotificationMessage(await auctionService.GetAuctionDtoByProductToAuctionIdAsync(productToAuction.Id, true)) //TODO: NE KÉRJÜK LE DB-BŐL!!! - j.
|
||||
Data = new BidNotificationMessage(await auctionService.GetAuctionDtoByProductToAuctionIdAsync(productToAuction.Id, true), bidsCount, "EMPTY") //TODO: NE KÉRJÜK LE DB-BŐL!!! - j.
|
||||
{
|
||||
ProductName = product.Name,
|
||||
CurrentPrice = productToAuction.CurrentPrice,
|
||||
NextStepAmount = stepAmount,
|
||||
NextBidPrice = nextBidPrice,
|
||||
ToasterMessage = "EMPTY", //TODO: - J.
|
||||
}.ToJson()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,9 @@ public class AuctionService : IAuctionService
|
|||
public Task<AuctionBid> GetLastAuctionBidByProductToAuctionIdAsync(int productToAuctionId)
|
||||
=> _ctx.GetLastAuctionBidByProductToAuctionId(productToAuctionId);
|
||||
|
||||
public Task<int> GetBidsCountByProductToAuctionIdAsync(int productToAuctionId)
|
||||
=> _ctx.GetBidsCountByProductToAuctionIdAsync(productToAuctionId);
|
||||
|
||||
public Task<AuctionBid> RevertAuctionBidByProductToAuctionIdAsync(int productToAuctionId)
|
||||
=> _ctx.RevertAuctionBidByProductToAuctionId(productToAuctionId);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ public interface IAuctionService
|
|||
/// The task result contains the bids
|
||||
/// </returns>
|
||||
Task<IPagedList<AuctionBid>> GetAllBidsAsync(int customerId = 0, int pageIndex = 0, int pageSize = int.MaxValue);
|
||||
|
||||
|
||||
Task<int> GetBidsCountByProductToAuctionIdAsync(int productToAuctionId);
|
||||
Task<AuctionBid> GetBidByIdAsync(int bidId);
|
||||
|
||||
Task InsertBidAsync(AuctionBid auctionBid);
|
||||
|
|
|
|||
Loading…
Reference in New Issue