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 { get; set; } protected override void Initialise() { MarketID = JSON.Value("MarketID") ?? 0; var biodata = JSON.Value("BioData"); BioData = new List(); if (biodata == null) { return; } foreach (JObject item in biodata) { BioData data = new BioData { Bonus = item.Value("Bonus") ?? 0, Value = item.Value("Value") ?? 0, Species = item.Value("Species") ?? "", Genus = item.Value("Genus") ?? "", GenusLocalised = item.Value("Genus_Localised") ?? "", SpeciesLocalised = item.Value("Species_Localised") ?? "" }; BioData.Add(data); } } public long TotalValue => BioData.Sum(x => x.TotalValue); } }