Knocks/BackEnd/Knoks.Core/Entities/KnokOngoing.cs

104 lines
3.5 KiB
C#

using Knoks.Core.Entities.Interfaces;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Text;
namespace Knoks.Core.Entities
{
//public class MicrosoftSecondsDateTimeConverter : DateTimeConverterBase
//{
// private static readonly DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
// public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
// {
// if (reader.TokenType == JsonToken.Null)
// return null;
// var token = JToken.Load(reader);
// if (token.Type == JTokenType.Integer)
// {
// var dt = epoch.AddMilliseconds((long)token);
// return dt;
// }
// // Not a Microsoft date.
// return new JsonSerializer().Deserialize(token.CreateReader(), objectType);
// }
// public override bool CanWrite { get { return true; } }
// public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
// {
// //writer.WriteValue((((DateTime)value).Ticks - epoch.Ticks) / 1000);
// writer.WriteValue(System.Convert.ToInt64((((DateTime)value) - epoch).TotalMilliseconds));
// }
//}
public class KnokOngoing : IApiResult
{
public Knokser Knokser { get; set; }
public OngoingKnok Knok { get; set; }
public OngoingStatus Status { get; set; }
public ChartItem[] ChartData { get; set; }
}
public class OngoingKnok
{
[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; }
//[JsonConverter(typeof(MicrosoftSecondsDateTimeConverter))]
public DateTime CreateDate { 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; }
[JsonIgnore]
public decimal PotentialProfitValue { get; set; }
public decimal CurrentProfit { get; set; }
public decimal PotentialProfit { get {
return this.PotentialProfitValue;
}
set { }
}
public decimal UserReview { get; set; }
public decimal UserReviewMax
{
get
{
return Constants.knokserFeedbackMax;
}
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 int MinutesLeftOnFeed { get; set; }
}
public class OngoingStatus
{
public int Purchases { get; set; }
}
}