merge
This commit is contained in:
commit
1e1d612b0f
|
|
@ -118,6 +118,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
|
|||
MessageType = "bidNotification",
|
||||
Data = new BidNotificationMessage
|
||||
{
|
||||
//AuctionDto = TODO: ??? - J.
|
||||
ProductName = viewModel.ProductName,
|
||||
BidPrice = viewModel.BidPrice.ToString(),
|
||||
NextStepAmount = viewModel.NextStepAmount.ToString()
|
||||
|
|
|
|||
|
|
@ -4,22 +4,34 @@ using Nop.Core.Configuration;
|
|||
using Nop.Core.Events;
|
||||
using Nop.Data;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||
|
||||
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 IQueryable<ProductToAuctionMapping> GetByAuctionAndProductId(int auctionId, int productId)
|
||||
private static bool HasActiveAuctionStatus(AuctionStatus auctionStatus)
|
||||
{
|
||||
return Table.Where(x => x.AuctionId == auctionId && x.ProductId == productId);
|
||||
return auctionStatus == AuctionStatus.Active;
|
||||
//return auctionStatus.HasFlag(AuctionStatus.Active) || auctionStatus.HasFlag(AuctionStatus.FirstWarning) || auctionStatus.HasFlag(AuctionStatus.SecondWarning);
|
||||
}
|
||||
|
||||
public IQueryable<ProductToAuctionMapping> GetByProductId(int productId)
|
||||
public IQueryable<ProductToAuctionMapping> GetByAuctionAndProductId(int auctionId, int productId, bool activeProductOnly = false)
|
||||
{
|
||||
return Table.Where(x => x.ProductId == productId);
|
||||
return GetProductToAuctionsByAuctionId(auctionId, activeProductOnly).Where(x => x.ProductId == productId);
|
||||
}
|
||||
|
||||
public IQueryable<ProductToAuctionMapping> GetByProductId(int productId, bool activeProductOnly = false)
|
||||
{
|
||||
return Table.Where(x => x.ProductId == productId && (!activeProductOnly || x.AuctionStatus == AuctionStatus.Active/*HasActiveAuctionStatus(x.AuctionStatus)*/));
|
||||
}
|
||||
|
||||
public IQueryable<ProductToAuctionMapping> GetProductToAuctionsByAuctionId(int auctionId, bool activeProductOnly = false)
|
||||
{
|
||||
return Table.Where(x => x.AuctionId == auctionId && (!activeProductOnly || x.AuctionStatus == AuctionStatus.Active/*HasActiveAuctionStatus(x.AuctionStatus)*/));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
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,11 @@
|
|||
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; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
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,6 +3,7 @@ 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.Hubs.Messages
|
||||
{
|
||||
|
|
@ -11,10 +12,14 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages
|
|||
/// 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
|
||||
/// </summary>
|
||||
public class BidNotificationMessage
|
||||
public class BidNotificationMessage : AuctionNotificationBase
|
||||
{
|
||||
public string ProductName { get; set; }
|
||||
public string BidPrice { get; set; }
|
||||
public string NextStepAmount { get; set; }
|
||||
|
||||
public BidNotificationMessage() { }
|
||||
public BidNotificationMessage(AuctionDto auctionDto):base(auctionDto) { }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
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,8 +12,7 @@ using Newtonsoft.Json.Serialization;
|
|||
using Microsoft.AspNetCore.SignalR;
|
||||
using Nop.Core;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||
using MimeKit;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities.Interfaces;
|
||||
using Nop.Services.Customers;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||
{
|
||||
|
|
@ -49,6 +48,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
|||
// return;
|
||||
//}
|
||||
|
||||
//TODO: lock-olni! - J.
|
||||
switch (message.MessageType)
|
||||
{
|
||||
case "BidRequestMessage":
|
||||
|
|
@ -56,7 +56,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
|||
break;
|
||||
|
||||
case "OpenItemRequestMessage":
|
||||
await HandleOpenItemMessageRequest(message.SenderId, message.Data.JsonTo<OpenItemRequest>());
|
||||
await HandleProductToAuctionStatusChangedRequest(message.SenderId, message.Data.JsonTo<AuctionProductStatusRequest>());
|
||||
break;
|
||||
|
||||
// Add other message types here
|
||||
|
|
@ -66,47 +66,53 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
|||
}
|
||||
}
|
||||
|
||||
private async Task HandleOpenItemMessageRequest(int senderId, OpenItemRequest openItemMessage)
|
||||
private async Task HandleProductToAuctionStatusChangedRequest(int senderId, AuctionProductStatusRequest auctionProductStatusRequest)
|
||||
{
|
||||
if (openItemMessage == null)
|
||||
if (auctionProductStatusRequest == null)
|
||||
{
|
||||
_logger.Error($"SignalRMessageHandler.HandleOpenItemMessageRequest(); openItemRequestMessage == null");
|
||||
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); auctionProductStatusRequest == null");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
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;
|
||||
await _logger.InformationAsync($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); ProductToAuctionMappingId: {auctionProductStatusRequest.ProductToAuctionId}; Status: {auctionProductStatusRequest.AuctionStatus}({(int)auctionProductStatusRequest.AuctionStatus})");
|
||||
|
||||
await _logger.InformationAsync($"SignalRMessageHandler.HandleOpenItemMessageRequest(); Auction {auction.Id}, ProducToAuction {productToAuction.Id}");
|
||||
//_auctionService.UpdateAuctionAsync(auction);
|
||||
//TODO: if IsAdmin.. - J.
|
||||
//TODO: if nincs aktív item.. - J.
|
||||
|
||||
var notification = new AuctionUpdateNotificationMessage
|
||||
var auction = await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(auctionProductStatusRequest.ProductToAuctionId);
|
||||
if (auction == null || auction.Closed)
|
||||
{
|
||||
AuctionId = auction.Id,
|
||||
};
|
||||
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); auction == null || auction.Closed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var bid = new MessageWrapper
|
||||
var productToAuction = await _auctionService.GetProductToAuctionMappingByIdAsync(auctionProductStatusRequest.ProductToAuctionId);
|
||||
if (productToAuction == null)
|
||||
{
|
||||
MessageType = "auctionEventNotification",
|
||||
SenderId = senderId,
|
||||
Data = notification.ToJson()
|
||||
|
||||
};
|
||||
|
||||
//await _hubContext.Clients.All.SendAsync("send", bid.ToJson());
|
||||
|
||||
_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)
|
||||
{
|
||||
|
|
@ -125,11 +131,20 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
|||
|
||||
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}");
|
||||
|
||||
if (bidRequestMessage.CustomerId != (await _workContext.GetCurrentCustomerAsync()).Id)
|
||||
//CustomerService a = new CustomerService()a.IsGuestAsync()
|
||||
var customer = await _workContext.GetCurrentCustomerAsync();
|
||||
if (customer == null || bidRequestMessage.CustomerId != customer.Id) //|| !customer.Active) //TODO: ??? - J.
|
||||
{
|
||||
_logger.Error($"SignalRMessageHandler.HandleBidRequest(); bidRequestMessage.CustomerId != (await _workContext.GetCurrentCustomerAsync()).Id");
|
||||
_logger.Error($"SignalRMessageHandler.HandleBidRequest(); customer == null || bidRequestMessage.CustomerId != customer.Id");
|
||||
return;
|
||||
}
|
||||
|
||||
var auction = await _auctionService.GetAuctionDtoByIdAsync(bidRequestMessage.AuctionId);
|
||||
if (auction.Closed)
|
||||
{
|
||||
_logger.Warning($"SignalRMessageHandler.HandleBidRequest(); auction.Closed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -140,15 +155,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.
|
||||
}
|
||||
|
||||
var mapping = await _auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(bidRequestMessage.AuctionId, bidRequestMessage.ProductId);
|
||||
if (mapping == null || mapping.Count == 0)
|
||||
var activeProductAuction = (await _auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(bidRequestMessage.AuctionId, bidRequestMessage.ProductId, true)).FirstOrDefault();
|
||||
if (activeProductAuction == null) //|| productAuction.WinnerCustomerId == customer.Id)
|
||||
{
|
||||
_logger.Error($"SignalRMessageHandler.HandleBidRequest(); mapping == null || mapping.Count == 0");
|
||||
return; //ha nincs ProductToAuction, akkor ne broadcast-eljük ki az invalid Bid-et! - J.
|
||||
_logger.Warning($"SignalRMessageHandler.HandleBidRequest(); activeProductAuction == null");
|
||||
return; //TODO: - J.
|
||||
}
|
||||
|
||||
var auctionBid = bidRequestMessage.CreateMainEntity();
|
||||
auctionBid.ProductAuctionMappingId = mapping.FirstOrDefault()!.Id;
|
||||
auctionBid.ProductAuctionMappingId = activeProductAuction.Id;
|
||||
|
||||
//TODO: validate the bidprice amount
|
||||
if (product.Price >= auctionBid.BidPrice)
|
||||
|
|
@ -164,12 +179,16 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
|||
product.Price = bidRequestMessage.BidPrice;
|
||||
await _productService.UpdateProductAsync(product);
|
||||
|
||||
activeProductAuction.StartingPrice = product.OldPrice;
|
||||
activeProductAuction.BidPrice = product.Price;
|
||||
await _auctionService.UpdateProductToAuctionMappingAsync(activeProductAuction);
|
||||
|
||||
// Optionally broadcast to all clients
|
||||
var bid = new MessageWrapper
|
||||
{
|
||||
MessageType = "bidNotification",
|
||||
SenderId = senderId,
|
||||
Data = new BidNotificationMessage
|
||||
Data = new BidNotificationMessage(await _auctionService.GetAuctionDtoWithProductByIdAsync(auction.Id, activeProductAuction.ProductId, true))
|
||||
{
|
||||
ProductName = auctionBid.ProductId.ToString(),
|
||||
BidPrice = auctionBid.BidPrice.ToString(CultureInfo.InvariantCulture),
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains;
|
|||
using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||
using Nop.Services.Logging;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||
|
|
@ -90,7 +91,7 @@ public class AuctionService : IAuctionService
|
|||
/// A task that represents the asynchronous operation
|
||||
/// The task result contains the bids
|
||||
/// </returns>
|
||||
public virtual async Task<IPagedList<AuctionBid>> GetAllBidsAsync(int customerId = 0, int pageIndex = 0, int pageSize = int.MaxValue)
|
||||
public async Task<IPagedList<AuctionBid>> GetAllBidsAsync(int customerId = 0, int pageIndex = 0, int pageSize = int.MaxValue)
|
||||
{
|
||||
var rez = new List<AuctionBid>();
|
||||
//var rez = await _shortTermCacheManager.GetAsync(async () => await _customerBidRepository.GetAllAsync(query =>
|
||||
|
|
@ -105,12 +106,12 @@ public class AuctionService : IAuctionService
|
|||
return new PagedList<AuctionBid>(rez, pageIndex, pageSize);
|
||||
}
|
||||
|
||||
public virtual async Task<AuctionBid> GetBidByIdAsync(int bidId)
|
||||
public async Task<AuctionBid> GetBidByIdAsync(int bidId)
|
||||
{
|
||||
return await _ctx.AuctionBids.GetByIdAsync(bidId);
|
||||
}
|
||||
|
||||
public virtual async Task InsertBidAsync(AuctionBid auctionBid)
|
||||
public async Task InsertBidAsync(AuctionBid auctionBid)
|
||||
{
|
||||
if (await ValidateAuctionBid(auctionBid))
|
||||
{
|
||||
|
|
@ -119,7 +120,7 @@ public class AuctionService : IAuctionService
|
|||
}
|
||||
}
|
||||
|
||||
public virtual async Task UpdateBidAsync(AuctionBid auctionBid)
|
||||
public async Task UpdateBidAsync(AuctionBid auctionBid)
|
||||
{
|
||||
if (await ValidateAuctionBid(auctionBid))
|
||||
{
|
||||
|
|
@ -133,19 +134,25 @@ public class AuctionService : IAuctionService
|
|||
/// </summary>
|
||||
/// <param name="pickupPoint">Pickup point</param>
|
||||
/// <returns>A task that represents the asynchronous operation</returns>
|
||||
public virtual async Task DeleteBidAsync(AuctionBid pickupPoint)
|
||||
public async Task DeleteBidAsync(AuctionBid pickupPoint)
|
||||
{
|
||||
await _ctx.AuctionBids.DeleteAsync(pickupPoint, false);
|
||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
||||
}
|
||||
|
||||
#region auctions
|
||||
public virtual async Task InsertAuctionAsync(Auction auction)
|
||||
public async Task InsertAuctionAsync(Auction auction)
|
||||
{
|
||||
await _ctx.Auctions.InsertAsync(auction, false);
|
||||
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()
|
||||
{
|
||||
return await _ctx.Auctions.GetAllAuctionsAsync();
|
||||
|
|
@ -153,8 +160,7 @@ public class AuctionService : IAuctionService
|
|||
|
||||
public async Task<List<ProductToAuctionMapping>> GetProductToAuctionsByAuctionIdAsync(int auctionId, bool onlyActiveItems = false)
|
||||
{
|
||||
//return (await _ctx.Auctions.GetAllAsync(auctions => auctions.OrderByDescending(x => x.StartDateUtc), _ => default)).ToList();
|
||||
return [];
|
||||
return await _ctx.ProductToAuctions.GetProductToAuctionsByAuctionId(auctionId, onlyActiveItems).ToListAsync();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
|
@ -166,13 +172,13 @@ public class AuctionService : IAuctionService
|
|||
return auction == null ? null : new AuctionDto(auction);
|
||||
}
|
||||
|
||||
public async Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId)
|
||||
public async Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId, bool activeProductOnly = false)
|
||||
{
|
||||
var auction = await _ctx.Auctions.GetByIdAsync(auctionId);
|
||||
if (auction == null) return null;
|
||||
|
||||
var auctionDto = new AuctionDto(auction);
|
||||
auctionDto.ProductToAuctionDtos.AddRange(await _ctx.ProductToAuctions.GetByAuctionAndProductId(auctionId, productId).Select(x => new ProductToAuctionDto(x)).ToListAsync());
|
||||
auctionDto.ProductToAuctionDtos.AddRange((await GetProductToAuctionByAuctionIdAndProductIdAsync(auctionId, productId, activeProductOnly)).Select(x => new ProductToAuctionDto(x)));
|
||||
|
||||
return auctionDto;
|
||||
}
|
||||
|
|
@ -206,9 +212,9 @@ public class AuctionService : IAuctionService
|
|||
return new List<ProductToAuctionMapping>(await _ctx.ProductToAuctions.GetByProductId(productId).ToListAsync());
|
||||
}
|
||||
|
||||
public async Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId)
|
||||
public async Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId, bool activeProductOnly = false)
|
||||
{
|
||||
return new List<ProductToAuctionMapping>(await _ctx.ProductToAuctions.GetByAuctionAndProductId(auctionId, productId).ToListAsync());
|
||||
return new List<ProductToAuctionMapping>(await _ctx.ProductToAuctions.GetByAuctionAndProductId(auctionId, productId, activeProductOnly).ToListAsync());
|
||||
}
|
||||
|
||||
public async Task<ProductToAuctionMapping> AssignProductToAuctionAsync(int productId, decimal startingPrice, decimal bidPrice, int auctionId)
|
||||
|
|
@ -226,7 +232,7 @@ public class AuctionService : IAuctionService
|
|||
StartingPrice = startingPrice,
|
||||
BidPrice = bidPrice,
|
||||
ProductAmount = 0,
|
||||
AuctionStatus = Domains.Enums.AuctionStatus.Active, //Ez miért Active alapból? - J.
|
||||
AuctionStatus = AuctionStatus.Active, //TODO: Ez miért Active alapból? - J.
|
||||
AuctionId = auctionId
|
||||
};
|
||||
|
||||
|
|
@ -242,5 +248,16 @@ public class AuctionService : IAuctionService
|
|||
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
|
||||
}
|
||||
|
|
@ -32,6 +32,7 @@ public interface IAuctionService
|
|||
Task DeleteBidAsync(AuctionBid pickupPoint);
|
||||
|
||||
Task InsertAuctionAsync(Auction auction);
|
||||
Task UpdateAuctionAsync(Auction auction);
|
||||
|
||||
Task<IList<Auction>> GetAllAuctionsAsync();
|
||||
|
||||
|
|
@ -40,7 +41,7 @@ public interface IAuctionService
|
|||
Task<AuctionDto> GetAuctionDtoByIdAsync(int auctionId);
|
||||
|
||||
|
||||
Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId);
|
||||
Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId, bool activeProductOnly);
|
||||
|
||||
Task<ProductToAuctionDto> GetProductToAuctionDtoByIdAsync(int productToAuctionId);
|
||||
|
||||
|
|
@ -49,5 +50,7 @@ public interface IAuctionService
|
|||
Task<ProductToAuctionMapping> AssignProductToAuctionAsync(int productId, decimal startingPrice, decimal bidPrice, int auctionId);
|
||||
Task<List<ProductToAuctionMapping>> GetProductToAuctionsByProductIdAsync(int productId);
|
||||
|
||||
Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId);
|
||||
Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId, bool activeProductOnly);
|
||||
Task<ProductToAuctionMapping> GetProductToAuctionMappingByIdAsync(int productToAuctionMappingId);
|
||||
Task UpdateProductToAuctionMappingAsync(ProductToAuctionMapping productToAuctionMapping);
|
||||
}
|
||||
Loading…
Reference in New Issue