public static void Exp(string stattype) { string file_name = "C:\\Users\\Jukich\\Desktop\\" + stattype + ".txt"; WPFContext context = new WPFContext(); StringBuilder strBuilder = new StringBuilder(); strBuilder.Append(stattype + " " + "Name" + System.Environment.NewLine); List <stat> ls = new List <stat>(); foreach (player p in context.Players) { stat s = new stat(); if (stattype == "Goals") { s.statistic = p.goalsScored; } else if (stattype == "Assists") { s.statistic = p.assists; } else if (stattype == "Appearances") { s.statistic = p.appearances; } else if (stattype == "Yellow cards") { s.statistic = p.YC; } else if (stattype == "Red cards") { s.statistic = p.Rc; } s.Name = p.name + " " + p.surename; ls.Add(s); // strBuilder.Append(s.statistic + " " + s.Name + System.Environment.NewLine); } var newList = ls.OrderByDescending(x => x.statistic).ToList(); foreach (stat st in newList) { strBuilder.Append(st.statistic + " " + st.Name + System.Environment.NewLine); } File.WriteAllText(file_name, strBuilder.ToString()); }
private void viewStat(string str, bool isadm, string username) { WPFContext context = new WPFContext(); List <stat> ls = new List <stat>(); foreach (player p in context.Players) { stat s = new stat(); if (str == "Goals") { s.statistic = p.goalsScored; } else if (str == "Assists") { s.statistic = p.assists; } else if (str == "Appearances") { s.statistic = p.appearances; } else if (str == "Yellow cards") { s.statistic = p.YC; } else if (str == "Red cards") { s.statistic = p.Rc; } s.Name = p.name + " " + p.surename; s.stattype = str; ls.Add(s); } flag = 1; StatPage st = new StatPage(ls, isadm, username); this.NavigationService.Navigate(st); }