using Newtonsoft.Json;
using Nop.Core.Domain.Directory;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
using Nop.Web.Framework.Models;

namespace Nop.Plugin.Misc.AuctionPlugin.Models
{
    public record AuctionPublicInfoModel : BaseNopModel
    {
        //[JsonIgnore]
        //[System.Text.Json.Serialization.JsonIgnore]
        public AuctionDto AuctionDto { get; set; }

        [JsonIgnore]
        [System.Text.Json.Serialization.JsonIgnore]
        public ProductToAuctionDto FirstProductToAuction { get; set; }

        public int ProductId => FirstProductToAuction?.ProductId ?? 0;
        public int ProductToAuctionMappingId => FirstProductToAuction?.ProductId ?? 0;
        public DateTime StartDate => AuctionDto?.StartDateUtc ?? DateTime.MinValue;
        public bool IsActive => FirstProductToAuction?.IsActiveItem ?? false;

        public string WorkingCurrencyCode { get; set; }
        public decimal WorkingCurrencyRate { get; set; }


        public AuctionPublicInfoModel()
        {
        }

        public AuctionPublicInfoModel(AuctionDto auctionDto) : this()
        {
            AuctionDto = auctionDto;

            //StartDate = AuctionDto.StartDateUtc;

            FirstProductToAuction = AuctionDto.ProductToAuctionDtos.FirstOrDefault();
            if (FirstProductToAuction == null) return;

            //ProductId = FirstProductToAuction.ProductId;
            //ProductToAuctionMappingId = FirstProductToAuction.Id;
            //IsActive = FirstProductToAuction.IsActiveItem;
        }
    }
}
