edjournal/SellOrganicDataEntry.cs

51 lines
1.6 KiB
C#
Raw Permalink Normal View History

2022-02-07 16:21:44 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace EDJournal {
public class BioData {
public string Genus { get; set; }
public string GenusLocalised { get; set; }
public string Species { get; set; }
public string SpeciesLocalised { get; set; }
public long Value { get; set; }
public long Bonus { get; set; }
public long TotalValue => Value + Bonus;
}
public class SellOrganicDataEntry : Entry {
public long MarketID { get; set; }
public List<BioData> BioData { get; set; }
protected override void Initialise() {
MarketID = JSON.Value<long?>("MarketID") ?? 0;
var biodata = JSON.Value<JArray>("BioData");
BioData = new List<BioData>();
if (biodata == null) {
return;
}
foreach (JObject item in biodata) {
BioData data = new BioData {
Bonus = item.Value<long?>("Bonus") ?? 0,
Value = item.Value<long?>("Value") ?? 0,
Species = item.Value<string>("Species") ?? "",
Genus = item.Value<string>("Genus") ?? "",
GenusLocalised = item.Value<string>("Genus_Localised") ?? "",
SpeciesLocalised = item.Value<string>("Species_Localised") ?? ""
};
BioData.Add(data);
}
}
2022-11-05 20:43:32 +01:00
public long TotalValue {
get { return BioData.Sum(x => x.TotalValue); }
}
2022-02-07 16:21:44 +01:00
}
}