using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces; using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities; using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities.Interfaces; using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums; using Nop.Plugin.Misc.AuctionPlugin.Services; namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos; public class ProductToAuctionDto : IProductToAuctionDto { public int Id { get; set; } public int ProductId { get; set; } public int AuctionId { get; set; } public int WinnerCustomerId { get; set; } public AuctionStatus AuctionStatus { get; set; } public decimal StartingPrice { get; set; } public decimal CurrentPrice { get; set; } public int ProductAmount { get; set; } public int SortIndex { get; set; } /// /// EGYELŐRE NE HASZNÁLD!!! - J. /// public decimal StepAmount { get; set; } public List AuctionBidDtos { get; } = []; public bool IsActiveItem => AuctionStatus is AuctionStatus.Active or AuctionStatus.FirstWarning or AuctionStatus.SecondWarning; public decimal BidPrice { get; set; } public ProductToAuctionDto() { } public ProductToAuctionDto(ProductToAuctionMapping productToAuction) : this(productToAuction, 0/*AuctionService.GetStepAmount(productToAuction.BidPrice)*/) { } /// /// /// /// /// EGYELŐRE NE HASZNÁLD!!! - J. public ProductToAuctionDto(ProductToAuctionMapping productToAuction, decimal stepAmount) : this() { if (productToAuction == null) return; if (stepAmount > 0) StepAmount = stepAmount; //else StepAmount = AuctionService.GetStepAmount(productToAuction.BidPrice); Id = productToAuction.Id; ProductId = productToAuction.ProductId; AuctionId = productToAuction.AuctionId; AuctionStatus = productToAuction.AuctionStatus; StartingPrice = productToAuction.StartingPrice; CurrentPrice = productToAuction.CurrentPrice; ProductAmount = productToAuction.ProductAmount; SortIndex = productToAuction.SortIndex; WinnerCustomerId = productToAuction.WinnerCustomerId; } public ProductToAuctionMapping CreateMainEntity() { var mainEntity = Activator.CreateInstance(); mainEntity.Id = Id; mainEntity.ProductId = ProductId; mainEntity.AuctionId = AuctionId; mainEntity.AuctionStatus = AuctionStatus; mainEntity.StartingPrice = StartingPrice; mainEntity.CurrentPrice = CurrentPrice; mainEntity.ProductAmount = ProductAmount; mainEntity.SortIndex = SortIndex; mainEntity.WinnerCustomerId = WinnerCustomerId; return mainEntity; } }