public void Input() { Console.WriteLine("Ladataan käyttäjiä..."); Console.WriteLine(); string json = File.ReadAllText("..\\..\\json\\Userdata.json"); // JObject o = JObject.Parse(json); JArray a = JArray.Parse(json); foreach (var user in a) { string usnm = user["Username"].ToString(); string pw = user["Password"].ToString(); Stocklist stocklist = new Stocklist(); JObject o = JObject.Parse(user["Stocks"].ToString()); JArray stocks = JArray.FromObject(o["Stocks"]); foreach (var s in stocks) { Stock newStock = new Stock(); newStock.ExchangeID = s["ExchangeID"].ToString(); newStock.BuyPrice = s.Value <double>("BuyPrice"); newStock.BuyDate = s["BuyDate"].ToString(); stocklist.Add(newStock); } this.Users.Add(new User(usnm, pw, stocklist)); } }
public static Load Loadings(Stocklist stocks) { Userlist u = new Userlist(); u.Input(); Console.WriteLine("Ladataan osaketietoja..."); Console.WriteLine(); //string json = File.ReadAllText("..\\..\\json\\Stocks.json"); ////JObject o = JObject.Parse(json); ////JArray a = (JArray)o["d"]; //JArray a = JArray.Parse(json); ////List<Stock> sto = a.ToObject<List<Stock>>(); //List<Stock> sto = new List<Stock>(); //foreach (var s in a) { // Stock stock = new Stock(); // stock.ExchangeID = s["ExchangeID"].ToString(); // stock.BuyPrice = s.Value<double>("BuyPrice"); // stock.BuyDate = s["BuyDate"].ToString(); // sto.Add(stock); //} //foreach (var stock in sto) { // stocks.Add(stock); //} return(new Load(u)); }
public BuyStock(Stock stock, User user) { this.Stocks = user.Stocks; InitializeComponent(); lblStockName.Text = stock.ExchangeID; lblStockPrice.Text = stock.SharePrice.ToString(); txtBuyPrice.Text = stock.SharePrice.ToString(); txtQuantity.KeyDown += KeyDown; }
public Porssisimulaattori() { this.stocklist = new Stocklist(); this.l = Features.Loadings(this.stocklist); this.users = l.Userlist; InitializeComponent(); lblLogIn.Text = "Kirjaudu sisään"; txtPassword.KeyDown += KeyDown; txtUsername.KeyDown += KeyDown; Update(); this.loadedStocks = new List <Stock>(); }