static void Main(string[] args) { BD.BDOpen(); //bool tmp = myBD.AddPerson("vovaa", "12345dfvvg"); bool tmp = BD.Update("vovaa", false); Console.WriteLine(tmp); //Console.WriteLine(BD.ShowInfo("vovaa")); //BD.Authorization("Masya", "bdc23"); //BD.Authorization("Masya", "bdc123"); //BD.AddPerson("Masya","bdc123"); //BD.ShowInfo("Vasya"); //BD.Update("Vasya", true); //BD.Update("Vasya", false); //BD.GetNumberOfGames("Vasya"); Statistic stat = new Statistic(); Console.ReadKey(true); }
public static MemoryStream ShowInfo(string name) { Statistic stat = new Statistic(); SQLiteCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM 'Users' WHERE Name =@name"; command.Parameters.Add(new SQLiteParameter("@name", @name)); SQLiteDataReader reader = command.ExecuteReader(); stat.id = reader["Id"].ToString(); ; stat.name = reader["Name"].ToString(); ; stat.all = Convert.ToInt32(reader["CntAll"]); ; stat.win = Convert.ToInt32(reader["CntWin"]); ; stat.lose = Convert.ToInt32(reader["CntLose"]); ; MemoryStream stream1 = new MemoryStream(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Statistic)); ser.WriteObject(stream1, stat); return stream1; //Deserilization //stream1.Position = 0; //StreamReader sr = new StreamReader(stream1); //Console.Write("JSON form of Statistic object: "); // Console.WriteLine(sr.ReadToEnd()); }