using System.ComponentModel.DataAnnotations.Schema;
using AyCode.Interfaces.Entities;
using LinqToDB.Mapping;
using Mango.Nop.Core.Entities;
using Newtonsoft.Json;
using Nop.Core;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities.Interfaces;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;

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

public partial class ProductToAuctionMapping : MgEntityBase, IProductToAuctionMapping
{
    public int ProductId { get; set; }
    public int AuctionId { get; set; }

    public int OrderId { get; set; }
    public int OrderItemId { get; set; }
    public int WinnerCustomerId { get; set; }
    public int? BiddingNumber { get; set; }
    public int BidsCount { get; set; }

    [NotMapped]
    [NotColumn]
    [JsonIgnore]
    [System.Text.Json.Serialization.JsonIgnore]
    public bool IsActiveItem => AuctionStatus is AuctionStatus.Active or AuctionStatus.FirstWarning or AuctionStatus.SecondWarning;

    public AuctionStatus AuctionStatus { get; set; }

    public decimal StartingPrice { get; set; }
    public decimal CurrentPrice { get; set; }
    public decimal MinimumPrice { get; set; }

    public int ProductAmount { get; set; } = 1;
    public int SortIndex { get; set; }

    [SkipValuesOnUpdate]
    public DateTime Created { get; set; }
    public DateTime Modified { get; set; }
}