using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;

namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;

public class AuctionBidDto : IAuctionBidDto
{
    public int Id { get; set; }
    public int ProductAuctionMappingId { get; set; }
    public int CustomerId { get; set; }
    public int ProductId { get; set; }
    public bool IsWinner { get; set; }
    public decimal BidPrice { get; set; }


    public AuctionBidDto()
    {
    }

    public AuctionBidDto(AuctionBid auctionBid)
    {
        if (auctionBid == null) return;

        Id = auctionBid.Id;
        ProductAuctionMappingId = auctionBid.ProductAuctionMappingId;
        CustomerId = auctionBid.CustomerId;
        ProductId = auctionBid.ProductId;
        IsWinner = auctionBid.IsWinner;
        BidPrice = auctionBid.BidPrice;
    }

    public AuctionBid CreateMainEntity()
    {
        var mainEntity = Activator.CreateInstance<AuctionBid>();

        mainEntity.Id = Id;
        mainEntity.ProductAuctionMappingId = ProductAuctionMappingId;
        mainEntity.CustomerId = CustomerId;
        mainEntity.ProductId = ProductId;
        mainEntity.IsWinner = IsWinner;
        mainEntity.BidPrice = BidPrice;


        return mainEntity;
    }
}