Compare commits
No commits in common. "d343a997bddfb8985cb72153d1a96d6a68289606" and "2c0e32b0937c0f8417aca47e8d501ee4c4e5101b" have entirely different histories.
d343a997bd
...
2c0e32b093
|
|
@ -118,7 +118,6 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
|
||||||
MessageType = "bidNotification",
|
MessageType = "bidNotification",
|
||||||
Data = new BidNotificationMessage
|
Data = new BidNotificationMessage
|
||||||
{
|
{
|
||||||
//AuctionDto = TODO: ??? - J.
|
|
||||||
ProductName = viewModel.ProductName,
|
ProductName = viewModel.ProductName,
|
||||||
BidPrice = viewModel.BidPrice.ToString(),
|
BidPrice = viewModel.BidPrice.ToString(),
|
||||||
NextStepAmount = viewModel.NextStepAmount.ToString()
|
NextStepAmount = viewModel.NextStepAmount.ToString()
|
||||||
|
|
|
||||||
|
|
@ -4,33 +4,22 @@ using Nop.Core.Configuration;
|
||||||
using Nop.Core.Events;
|
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;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
||||||
|
|
||||||
public class ProductToAuctionDbTable : MgDbTableBase<ProductToAuctionMapping>
|
public class ProductToAuctionDbTable: MgDbTableBase<ProductToAuctionMapping>
|
||||||
{
|
{
|
||||||
public ProductToAuctionDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
|
public ProductToAuctionDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasActiveAuctionStatus(AuctionStatus auctionStatus)
|
public IQueryable<ProductToAuctionMapping> GetByAuctionAndProductId(int auctionId, int productId)
|
||||||
{
|
{
|
||||||
return auctionStatus.HasFlag(AuctionStatus.Active) || auctionStatus.HasFlag(AuctionStatus.FirstWarning) || auctionStatus.HasFlag(AuctionStatus.SecondWarning);
|
return Table.Where(x => x.AuctionId == auctionId && x.ProductId == productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueryable<ProductToAuctionMapping> GetByAuctionAndProductId(int auctionId, int productId, bool activeProductOnly = false)
|
public IQueryable<ProductToAuctionMapping> GetByProductId(int productId)
|
||||||
{
|
{
|
||||||
return GetProductToAuctionsByAuctionId(auctionId, activeProductOnly).Where(x => x.ProductId == productId);
|
return Table.Where(x => x.ProductId == productId);
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<ProductToAuctionMapping> GetByProductId(int productId, bool activeProductOnly = false)
|
|
||||||
{
|
|
||||||
return Table.Where(x => x.ProductId == productId && (!activeProductOnly || HasActiveAuctionStatus(x.AuctionStatus)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<ProductToAuctionMapping> GetProductToAuctionsByAuctionId(int auctionId, bool activeProductOnly = false)
|
|
||||||
{
|
|
||||||
return Table.Where(x => x.AuctionId == auctionId && (!activeProductOnly || HasActiveAuctionStatus(x.AuctionStatus)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
|
||||||
|
|
||||||
public abstract class AuctionNotificationBase
|
|
||||||
{
|
|
||||||
public AuctionDto AuctionDto { get; set; }
|
|
||||||
|
|
||||||
protected AuctionNotificationBase(){}
|
|
||||||
|
|
||||||
protected AuctionNotificationBase(AuctionDto auctionDto)
|
|
||||||
{
|
|
||||||
AuctionDto = auctionDto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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) { }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages
|
|
||||||
{
|
|
||||||
public class AuctionProductStatusRequest// : AuctionBidDto
|
|
||||||
{
|
|
||||||
public int ProductToAuctionId { get; set; }
|
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
|
||||||
|
|
||||||
public class AuctionStatusNotification : AuctionNotificationBase
|
|
||||||
{
|
|
||||||
public AuctionStatusNotification() { }
|
|
||||||
public AuctionStatusNotification(AuctionDto auctionDto):base(auctionDto) { }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages
|
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages
|
||||||
{
|
{
|
||||||
|
|
@ -12,14 +11,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages
|
||||||
/// this message sends update to the clients. so it sends current (the already winner) price,
|
/// this message sends update to the clients. so it sends current (the already winner) price,
|
||||||
/// sends the ACTUAL bidstep, so the new price, and next bid can be calculated on the client side
|
/// sends the ACTUAL bidstep, so the new price, and next bid can be calculated on the client side
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BidNotificationMessage : AuctionNotificationBase
|
public class BidNotificationMessage
|
||||||
{
|
{
|
||||||
public string ProductName { get; set; }
|
public string ProductName { get; set; }
|
||||||
public string BidPrice { get; set; }
|
public string BidPrice { get; set; }
|
||||||
public string NextStepAmount { get; set; }
|
public string NextStepAmount { get; set; }
|
||||||
|
|
||||||
public BidNotificationMessage() { }
|
|
||||||
public BidNotificationMessage(AuctionDto auctionDto):base(auctionDto) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
|
{
|
||||||
|
public class OpenItemRequest : AuctionBidDto
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,6 @@ using Newtonsoft.Json.Serialization;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||||
using Nop.Services.Customers;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
{
|
{
|
||||||
|
|
@ -48,7 +47,6 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//TODO: lock-olni! - J.
|
|
||||||
switch (message.MessageType)
|
switch (message.MessageType)
|
||||||
{
|
{
|
||||||
case "BidRequestMessage":
|
case "BidRequestMessage":
|
||||||
|
|
@ -56,7 +54,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "OpenItemRequestMessage":
|
case "OpenItemRequestMessage":
|
||||||
await HandleProductToAuctionStatusChangedRequest(message.SenderId, message.Data.JsonTo<AuctionProductStatusRequest>());
|
await HandleOpenItemMessageRequest(message.SenderId, message.Data.JsonTo<OpenItemRequest>());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Add other message types here
|
// Add other message types here
|
||||||
|
|
@ -66,53 +64,28 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task HandleProductToAuctionStatusChangedRequest(int senderId, AuctionProductStatusRequest auctionProductStatusRequest)
|
private async Task HandleOpenItemMessageRequest(int SenderId, OpenItemRequest openItemMessage)
|
||||||
{
|
{
|
||||||
if (auctionProductStatusRequest == null)
|
if (openItemMessage == null)
|
||||||
{
|
{
|
||||||
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); auctionProductStatusRequest == null");
|
_logger.Error($"SignalRMessageHandler.HandleOpenItemMessageRequest(); openItemRequestMessage == null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _logger.InformationAsync($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); ProductToAuctionMappingId: {auctionProductStatusRequest.ProductToAuctionId}; Status: {auctionProductStatusRequest.AuctionStatus}({(int)auctionProductStatusRequest.AuctionStatus})");
|
await _logger.InformationAsync($"SignalRMessageHandler.HandleOpenItemMessageRequest(); Item to open: - ProductToAuctionMappingId: {openItemMessage.ProductAuctionMappingId}");
|
||||||
|
|
||||||
|
//get auction
|
||||||
|
var auction = await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(openItemMessage.ProductAuctionMappingId);
|
||||||
|
//get productToAuction
|
||||||
|
var productToAuction = await _auctionService.GetProductToAuctionDtoByIdAsync(openItemMessage.ProductAuctionMappingId);
|
||||||
|
|
||||||
|
auction.Closed = false;
|
||||||
|
|
||||||
//TODO: if IsAdmin.. - J.
|
await _logger.InformationAsync($"SignalRMessageHandler.HandleOpenItemMessageRequest(); Auction {auction.Id}, ProducToAuction {productToAuction.Id}");
|
||||||
//TODO: if nincs aktív item.. - J.
|
//_auctionService.UpdateAuctionAsync(auction);
|
||||||
|
|
||||||
var auction = await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(auctionProductStatusRequest.ProductToAuctionId);
|
|
||||||
if (auction == null || auction.Closed)
|
|
||||||
{
|
|
||||||
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); auction == null || auction.Closed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var productToAuction = await _auctionService.GetProductToAuctionMappingByIdAsync(auctionProductStatusRequest.ProductToAuctionId);
|
|
||||||
if (productToAuction == null)
|
|
||||||
{
|
|
||||||
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); productToAuction == null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (auctionProductStatusRequest.AuctionStatus)
|
|
||||||
{
|
|
||||||
case AuctionStatus.FirstWarning:
|
|
||||||
productToAuction.AuctionStatus = AuctionStatus.Active | AuctionStatus.FirstWarning;
|
|
||||||
break;
|
|
||||||
case AuctionStatus.SecondWarning:
|
|
||||||
productToAuction.AuctionStatus = AuctionStatus.Active | AuctionStatus.SecondWarning;
|
|
||||||
break;
|
|
||||||
case AuctionStatus.None:
|
|
||||||
case AuctionStatus.Active:
|
|
||||||
case AuctionStatus.SoldOut:
|
|
||||||
case AuctionStatus.NotSold:
|
|
||||||
default:
|
|
||||||
auctionProductStatusRequest.AuctionStatus = auctionProductStatusRequest.AuctionStatus;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
await _auctionService.UpdateProductToAuctionMappingAsync(productToAuction);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -131,20 +104,11 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _logger.InformationAsync($"SignalRMessageHandler.HandleBidRequest(); Bid received; Auction: {bidRequestMessage.AuctionId}; Product: {bidRequestMessage.ProductId}; Bid: {bidRequestMessage.BidPrice}; Customer: {bidRequestMessage.CustomerId}");
|
await _logger.InformationAsync($"SignalRMessageHandler.HandleBidRequest(); Bid received: - Auction: {bidRequestMessage.AuctionId} Product: {bidRequestMessage.ProductId} - Bid: {bidRequestMessage.BidPrice} - Customer: {bidRequestMessage.CustomerId}");
|
||||||
|
|
||||||
//CustomerService a = new CustomerService()a.IsGuestAsync()
|
if (bidRequestMessage.CustomerId != (await _workContext.GetCurrentCustomerAsync()).Id)
|
||||||
var customer = await _workContext.GetCurrentCustomerAsync();
|
|
||||||
if (customer == null || bidRequestMessage.CustomerId != customer.Id) //|| !customer.Active) //TODO: ??? - J.
|
|
||||||
{
|
{
|
||||||
_logger.Error($"SignalRMessageHandler.HandleBidRequest(); customer == null || bidRequestMessage.CustomerId != customer.Id");
|
_logger.Error($"SignalRMessageHandler.HandleBidRequest(); bidRequestMessage.CustomerId != (await _workContext.GetCurrentCustomerAsync()).Id");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var auction = await _auctionService.GetAuctionDtoByIdAsync(bidRequestMessage.AuctionId);
|
|
||||||
if (auction.Closed)
|
|
||||||
{
|
|
||||||
_logger.Warning($"SignalRMessageHandler.HandleBidRequest(); auction.Closed");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,15 +119,15 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
return; //ha nincs product vagy exception van, akkor ne broadcast-eljük ki az invalid Bid-et! - J.
|
return; //ha nincs product vagy exception van, akkor ne broadcast-eljük ki az invalid Bid-et! - J.
|
||||||
}
|
}
|
||||||
|
|
||||||
var activeProductAuction = (await _auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(bidRequestMessage.AuctionId, bidRequestMessage.ProductId, true)).FirstOrDefault();
|
var mapping = await _auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(bidRequestMessage.AuctionId, bidRequestMessage.ProductId);
|
||||||
if (activeProductAuction == null) //|| productAuction.WinnerCustomerId == customer.Id)
|
if (mapping == null || mapping.Count == 0)
|
||||||
{
|
{
|
||||||
_logger.Warning($"SignalRMessageHandler.HandleBidRequest(); activeProductAuction == null");
|
_logger.Error($"SignalRMessageHandler.HandleBidRequest(); mapping == null || mapping.Count == 0");
|
||||||
return; //TODO: - J.
|
return; //ha nincs ProductToAuction, akkor ne broadcast-eljük ki az invalid Bid-et! - J.
|
||||||
}
|
}
|
||||||
|
|
||||||
var auctionBid = bidRequestMessage.CreateMainEntity();
|
var auctionBid = bidRequestMessage.CreateMainEntity();
|
||||||
auctionBid.ProductAuctionMappingId = activeProductAuction.Id;
|
auctionBid.ProductAuctionMappingId = mapping.FirstOrDefault()!.Id;
|
||||||
|
|
||||||
//TODO: validate the bidprice amount
|
//TODO: validate the bidprice amount
|
||||||
if (product.Price >= auctionBid.BidPrice)
|
if (product.Price >= auctionBid.BidPrice)
|
||||||
|
|
@ -179,16 +143,12 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
product.Price = bidRequestMessage.BidPrice;
|
product.Price = bidRequestMessage.BidPrice;
|
||||||
await _productService.UpdateProductAsync(product);
|
await _productService.UpdateProductAsync(product);
|
||||||
|
|
||||||
activeProductAuction.StartingPrice = product.OldPrice;
|
|
||||||
activeProductAuction.BidPrice = product.Price;
|
|
||||||
await _auctionService.UpdateProductToAuctionMappingAsync(activeProductAuction);
|
|
||||||
|
|
||||||
// Optionally broadcast to all clients
|
// Optionally broadcast to all clients
|
||||||
var bid = new MessageWrapper
|
var bid = new MessageWrapper
|
||||||
{
|
{
|
||||||
MessageType = "bidNotification",
|
MessageType = "bidNotification",
|
||||||
SenderId = senderId,
|
SenderId = senderId,
|
||||||
Data = new BidNotificationMessage(await _auctionService.GetAuctionDtoWithProductByIdAsync(auction.Id, activeProductAuction.ProductId, true))
|
Data = new BidNotificationMessage
|
||||||
{
|
{
|
||||||
ProductName = auctionBid.ProductId.ToString(),
|
ProductName = auctionBid.ProductId.ToString(),
|
||||||
BidPrice = auctionBid.BidPrice.ToString(CultureInfo.InvariantCulture),
|
BidPrice = auctionBid.BidPrice.ToString(CultureInfo.InvariantCulture),
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
|
||||||
using Nop.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
|
@ -91,7 +90,7 @@ public class AuctionService : IAuctionService
|
||||||
/// A task that represents the asynchronous operation
|
/// A task that represents the asynchronous operation
|
||||||
/// The task result contains the bids
|
/// The task result contains the bids
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<IPagedList<AuctionBid>> GetAllBidsAsync(int customerId = 0, int pageIndex = 0, int pageSize = int.MaxValue)
|
public virtual async Task<IPagedList<AuctionBid>> GetAllBidsAsync(int customerId = 0, int pageIndex = 0, int pageSize = int.MaxValue)
|
||||||
{
|
{
|
||||||
var rez = new List<AuctionBid>();
|
var rez = new List<AuctionBid>();
|
||||||
//var rez = await _shortTermCacheManager.GetAsync(async () => await _customerBidRepository.GetAllAsync(query =>
|
//var rez = await _shortTermCacheManager.GetAsync(async () => await _customerBidRepository.GetAllAsync(query =>
|
||||||
|
|
@ -106,12 +105,12 @@ public class AuctionService : IAuctionService
|
||||||
return new PagedList<AuctionBid>(rez, pageIndex, pageSize);
|
return new PagedList<AuctionBid>(rez, pageIndex, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<AuctionBid> GetBidByIdAsync(int bidId)
|
public virtual async Task<AuctionBid> GetBidByIdAsync(int bidId)
|
||||||
{
|
{
|
||||||
return await _ctx.AuctionBids.GetByIdAsync(bidId);
|
return await _ctx.AuctionBids.GetByIdAsync(bidId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InsertBidAsync(AuctionBid auctionBid)
|
public virtual async Task InsertBidAsync(AuctionBid auctionBid)
|
||||||
{
|
{
|
||||||
if (await ValidateAuctionBid(auctionBid))
|
if (await ValidateAuctionBid(auctionBid))
|
||||||
{
|
{
|
||||||
|
|
@ -120,7 +119,7 @@ public class AuctionService : IAuctionService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateBidAsync(AuctionBid auctionBid)
|
public virtual async Task UpdateBidAsync(AuctionBid auctionBid)
|
||||||
{
|
{
|
||||||
if (await ValidateAuctionBid(auctionBid))
|
if (await ValidateAuctionBid(auctionBid))
|
||||||
{
|
{
|
||||||
|
|
@ -134,25 +133,19 @@ public class AuctionService : IAuctionService
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pickupPoint">Pickup point</param>
|
/// <param name="pickupPoint">Pickup point</param>
|
||||||
/// <returns>A task that represents the asynchronous operation</returns>
|
/// <returns>A task that represents the asynchronous operation</returns>
|
||||||
public async Task DeleteBidAsync(AuctionBid pickupPoint)
|
public virtual async Task DeleteBidAsync(AuctionBid pickupPoint)
|
||||||
{
|
{
|
||||||
await _ctx.AuctionBids.DeleteAsync(pickupPoint, false);
|
await _ctx.AuctionBids.DeleteAsync(pickupPoint, false);
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region auctions
|
#region auctions
|
||||||
public async Task InsertAuctionAsync(Auction auction)
|
public virtual async Task InsertAuctionAsync(Auction auction)
|
||||||
{
|
{
|
||||||
await _ctx.Auctions.InsertAsync(auction, false);
|
await _ctx.Auctions.InsertAsync(auction, false);
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAuctionAsync(Auction auction)
|
|
||||||
{
|
|
||||||
await _ctx.Auctions.UpdateAsync(auction);
|
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IList<Auction>> GetAllAuctionsAsync()
|
public async Task<IList<Auction>> GetAllAuctionsAsync()
|
||||||
{
|
{
|
||||||
return await _ctx.Auctions.GetAllAuctionsAsync();
|
return await _ctx.Auctions.GetAllAuctionsAsync();
|
||||||
|
|
@ -160,7 +153,8 @@ public class AuctionService : IAuctionService
|
||||||
|
|
||||||
public async Task<List<ProductToAuctionMapping>> GetProductToAuctionsByAuctionIdAsync(int auctionId, bool onlyActiveItems = false)
|
public async Task<List<ProductToAuctionMapping>> GetProductToAuctionsByAuctionIdAsync(int auctionId, bool onlyActiveItems = false)
|
||||||
{
|
{
|
||||||
return await _ctx.ProductToAuctions.GetProductToAuctionsByAuctionId(auctionId, onlyActiveItems).ToListAsync();
|
//return (await _ctx.Auctions.GetAllAsync(auctions => auctions.OrderByDescending(x => x.StartDateUtc), _ => default)).ToList();
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -172,13 +166,13 @@ public class AuctionService : IAuctionService
|
||||||
return auction == null ? null : new AuctionDto(auction);
|
return auction == null ? null : new AuctionDto(auction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId, bool activeProductOnly = false)
|
public async Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId)
|
||||||
{
|
{
|
||||||
var auction = await _ctx.Auctions.GetByIdAsync(auctionId);
|
var auction = await _ctx.Auctions.GetByIdAsync(auctionId);
|
||||||
if (auction == null) return null;
|
if (auction == null) return null;
|
||||||
|
|
||||||
var auctionDto = new AuctionDto(auction);
|
var auctionDto = new AuctionDto(auction);
|
||||||
auctionDto.ProductToAuctionDtos.AddRange((await GetProductToAuctionByAuctionIdAndProductIdAsync(auctionId, productId, activeProductOnly)).Select(x => new ProductToAuctionDto(x)));
|
auctionDto.ProductToAuctionDtos.AddRange(await _ctx.ProductToAuctions.GetByAuctionAndProductId(auctionId, productId).Select(x => new ProductToAuctionDto(x)).ToListAsync());
|
||||||
|
|
||||||
return auctionDto;
|
return auctionDto;
|
||||||
}
|
}
|
||||||
|
|
@ -212,9 +206,9 @@ public class AuctionService : IAuctionService
|
||||||
return new List<ProductToAuctionMapping>(await _ctx.ProductToAuctions.GetByProductId(productId).ToListAsync());
|
return new List<ProductToAuctionMapping>(await _ctx.ProductToAuctions.GetByProductId(productId).ToListAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId, bool activeProductOnly = false)
|
public async Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId)
|
||||||
{
|
{
|
||||||
return new List<ProductToAuctionMapping>(await _ctx.ProductToAuctions.GetByAuctionAndProductId(auctionId, productId, activeProductOnly).ToListAsync());
|
return new List<ProductToAuctionMapping>(await _ctx.ProductToAuctions.GetByAuctionAndProductId(auctionId, productId).ToListAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ProductToAuctionMapping> AssignProductToAuctionAsync(int productId, decimal startingPrice, decimal bidPrice, int auctionId)
|
public async Task<ProductToAuctionMapping> AssignProductToAuctionAsync(int productId, decimal startingPrice, decimal bidPrice, int auctionId)
|
||||||
|
|
@ -232,7 +226,7 @@ public class AuctionService : IAuctionService
|
||||||
StartingPrice = startingPrice,
|
StartingPrice = startingPrice,
|
||||||
BidPrice = bidPrice,
|
BidPrice = bidPrice,
|
||||||
ProductAmount = 0,
|
ProductAmount = 0,
|
||||||
AuctionStatus = AuctionStatus.Active, //TODO: Ez miért Active alapból? - J.
|
AuctionStatus = Domains.Enums.AuctionStatus.Active, //Ez miért Active alapból? - J.
|
||||||
AuctionId = auctionId
|
AuctionId = auctionId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -248,16 +242,5 @@ public class AuctionService : IAuctionService
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ProductToAuctionMapping> GetProductToAuctionMappingByIdAsync(int productToAuctionMappingId)
|
|
||||||
{
|
|
||||||
return await _ctx.ProductToAuctions.GetByIdAsync(productToAuctionMappingId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task UpdateProductToAuctionMappingAsync(ProductToAuctionMapping productToAuctionMapping)
|
|
||||||
{
|
|
||||||
await _ctx.ProductToAuctions.UpdateAsync(productToAuctionMapping);
|
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Dtos
|
#endregion Dtos
|
||||||
}
|
}
|
||||||
|
|
@ -32,7 +32,6 @@ public interface IAuctionService
|
||||||
Task DeleteBidAsync(AuctionBid pickupPoint);
|
Task DeleteBidAsync(AuctionBid pickupPoint);
|
||||||
|
|
||||||
Task InsertAuctionAsync(Auction auction);
|
Task InsertAuctionAsync(Auction auction);
|
||||||
Task UpdateAuctionAsync(Auction auction);
|
|
||||||
|
|
||||||
Task<IList<Auction>> GetAllAuctionsAsync();
|
Task<IList<Auction>> GetAllAuctionsAsync();
|
||||||
|
|
||||||
|
|
@ -41,7 +40,7 @@ public interface IAuctionService
|
||||||
Task<AuctionDto> GetAuctionDtoByIdAsync(int auctionId);
|
Task<AuctionDto> GetAuctionDtoByIdAsync(int auctionId);
|
||||||
|
|
||||||
|
|
||||||
Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId, bool activeProductOnly);
|
Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId);
|
||||||
|
|
||||||
Task<ProductToAuctionDto> GetProductToAuctionDtoByIdAsync(int productToAuctionId);
|
Task<ProductToAuctionDto> GetProductToAuctionDtoByIdAsync(int productToAuctionId);
|
||||||
|
|
||||||
|
|
@ -50,7 +49,5 @@ public interface IAuctionService
|
||||||
Task<ProductToAuctionMapping> AssignProductToAuctionAsync(int productId, decimal startingPrice, decimal bidPrice, int auctionId);
|
Task<ProductToAuctionMapping> AssignProductToAuctionAsync(int productId, decimal startingPrice, decimal bidPrice, int auctionId);
|
||||||
Task<List<ProductToAuctionMapping>> GetProductToAuctionsByProductIdAsync(int productId);
|
Task<List<ProductToAuctionMapping>> GetProductToAuctionsByProductIdAsync(int productId);
|
||||||
|
|
||||||
Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId, bool activeProductOnly);
|
Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId);
|
||||||
Task<ProductToAuctionMapping> GetProductToAuctionMappingByIdAsync(int productToAuctionMappingId);
|
|
||||||
Task UpdateProductToAuctionMappingAsync(ProductToAuctionMapping productToAuctionMapping);
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue