using Knoks.Core.Entities.Interfaces;
using Newtonsoft.Json;
using System;

namespace Knoks.Core.Entities
{
    public class KnokEnded : IApiResult
    {
        public Knokser Knokser { get; set; }
        public EndedKnok Knok { get; set; }
        public EndedStatus Status { get; set; }
        public ChartItem[] ChartData { get; set; }
    }
    
    public class EndedKnok
    {
        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        public long? KnokId { get; set; } 
        public string Currency1 { get; set; }
        public string Currency2 { get; set; }
        public string Currency { get; set; } 
        public string MarketDisplayName { get; set; } 
        public int ExchangeId { get; set; } 
        public string ExchangeName { get; set; }
        public DateTime CreateDate { get; set; }
        public DateTime CloseDate { get; set; }
        public int Duration { get; set; } 
        public decimal EntryPriceFrom { get; set; } 
        public decimal EntryPriceTo { get; set; } 
        public decimal ExitPriceFrom { get; set; } 
        public decimal ExitPriceTo { get; set; } 
        public decimal StopLoss { get; set; } 
        public decimal? CurrentPrice { get; set; } 
        public decimal UserReview { get; set; }
        public decimal UserReviewMax {
            get {                
                return  Constants.knokserFeedbackMax;
            }
            set { }
        }
        [JsonIgnore]
        public decimal? TraderUserReviewMax { get; set; }
        [JsonIgnore]
        public decimal? KnokserUserReviewMax { get; set; }
        public decimal? DistanceFromTarget { get; set; } 
        [JsonIgnore]
        public decimal PotentialProfitValue { get; set; } 
        public decimal CurrentProfit { get; set; } 
        public decimal PotentialProfit
        {
            get
            {
                return this.PotentialProfitValue;
            }
            set { }
        }
        public KnokEndedStatus EndedStatus { get; set; }
        public short Precision { get; set; }
        public decimal PricePool
        {
            get
            {
                return this.PricePoolData.HasValue ? this.PricePoolData.Value * Constants.knokserCommission : 0;
            }
            set { }
        }
        [JsonIgnore]
        public decimal? PricePoolData { get; set; }
        public bool? FeedbackExists { get; set; }
    }

    public class EndedStatus
    {
        public int Purchases { get; set; }
    }
}
