using ExCSS;
using Newtonsoft.Json;
using Nop.Core.Domain.Directory;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
using Nop.Web.Framework.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nop.Plugin.Misc.AuctionPlugin.Models
{
    public record ProductBidBoxViewModel: 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 ProductToAuctionId { get; set; }
        public bool IsAdmin { get; set; }
        public bool IsGuest { get; set; }

        public int AuctionId { get; set; }
        public bool AuctionClosed { get; set; }
        public bool IsItemActive => FirstProductToAuction?.IsActiveItem ?? false;
        public AuctionStatus AuctionStatus { get; set; }
        public int ProductId { get; set; }

        public string NextProductUrl { get; set; }
        public string NextProductImageUrl { get; set; }
        public string NextProductName { get; set; }

        public string LastProductUrl { get; set; }
        public string LastProductImageUrl { get; set; }
        public string LastProductName { get; set; }

        public int CustomerId { get; set; }

        public Currency WorkingCurrency { get; set; }

        public string WidgetZone { get; set; }


        #region debug fields to be removed

        public decimal? BasePrice { get; set; }
        public decimal? BasePriceInWorkingCurrency { get; set; }

        #endregion

        #region visible
        public decimal LicitStep { get; set; }
        public decimal? CurrentPrice { get; set; }
        public decimal NextBidPrice { get; set; }

        public decimal LicitStepInWorkingCurrency { get; set; }
        public decimal? CurrentPriceInWorkingCurrency { get; set; }
        public decimal NextBidPriceInWorkingCurrency { get; set; }

        #endregion visible

        public ProductBidBoxViewModel() { }

        public ProductBidBoxViewModel(AuctionDto auctionDto) : this()
        {
            AuctionDto = auctionDto;
            AuctionId = auctionDto.Id;

            FirstProductToAuction = AuctionDto.ProductToAuctionDtos.FirstOrDefault();
            if (FirstProductToAuction == null) return;
            
            ProductId = FirstProductToAuction.ProductId;
            ProductToAuctionId = FirstProductToAuction.Id;            
        }
    }
}
