Beispiel #1
0
 public UserProfile(String login, String password, Role role, int id)
 {
     this.userId = id;
     this.login = login;
     this.password = password;
     this.role = role;
     statistic = new Statistic(userId);
 }
Beispiel #2
0
        public static Statistic GetUserStatistic(int userId)
        {
            Statistic statistic;
            connection.Open();
            command = new SQLiteCommand("SELECT * FROM 'Statistic' WHERE user_id = @param1;", connection);
            command.Parameters.Add(new SQLiteParameter("@param1", userId));
            reader = command.ExecuteReader();

            List<ExerciseResultInfo> results = new List<ExerciseResultInfo>();
            ExerciseResultInfo resultInfo;
            while (reader.Read())
            {
                int level = Convert.ToInt32(reader["level"]);
                int exerciseId = Convert.ToInt32(reader["exercise_id"]);
                int assesment = Convert.ToInt32(reader["assesment"]);
                DateTime dateOfPassing = Convert.ToDateTime(reader["dateOfPass"]);
                int speed = Convert.ToInt32(reader["speed"]);
                int errors = Convert.ToInt32(reader["errors"]);
                resultInfo = new ExerciseResultInfo(exerciseId, dateOfPassing, errors, assesment, speed);
                results.Add(resultInfo);
            }

            statistic = new Statistic(userId, results);
            connection.Close();

            return statistic;
        }
Beispiel #3
0
        public static void saveUserStatictis(Statistic statistic)
        {
            connection.Open();
            command = new SQLiteCommand("INSERT INTO 'Statistic' (level,exercise_id,assesment,dateOfPass,speed,user_id,errors) VALUES (@param1,@param2,@param3,@param4,@param5,@param6,@param7)", connection);

            List<ExerciseResultInfo> resultsInfo = statistic.getResultsInfo();
            foreach(ExerciseResultInfo resultInfo in resultsInfo)
            {
                command.Parameters.Add(new SQLiteParameter("@param1", resultInfo.level));
                command.Parameters.Add(new SQLiteParameter("@param2", resultInfo.exerciseId));
                command.Parameters.Add(new SQLiteParameter("@param3", resultInfo.assesment));
                command.Parameters.Add(new SQLiteParameter("@param4", resultInfo.dateOfPassing));
                command.Parameters.Add(new SQLiteParameter("@param5", resultInfo.speed));
                command.Parameters.Add(new SQLiteParameter("@param6", statistic.userId));
                command.Parameters.Add(new SQLiteParameter("@param7", resultInfo.errorsCount));
            }

            command.ExecuteNonQuery();

            connection.Close();
        }