public static List <MoodleEnrollment> GetEnrollmentList()
        {
            List <MoodleEnrollment> enrollmentList = new List <MoodleEnrollment>();

            var connection = DBMethods.GetConnection();
            var command    = DBMethods.GetCommand(connection, "Enrollments");
            int i          = 0; // Row index for DataReader

            connection.Open();

            try
            {
                MySqlDataReader dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    if (dataReader.IsDBNull(i))
                    {
                        Console.WriteLine("Null!");
                        break;
                    }
                    else
                    {
                        MoodleEnrollment enrollment = new MoodleEnrollment()
                        {
                            UserId   = dataReader.GetInt32(0),
                            CourseId = dataReader.GetInt32(1),
                            RoleId   = dataReader.GetInt32(2)
                        };

                        enrollmentList.Add(enrollment);
                    }
                    i++;
                }
                //Close the reader
                dataReader.Close();
            }
            finally
            {
                //Close the connection
                connection.Close();
            }
            return(enrollmentList);
        }
 public string GetEnrolData(MoodleEnrollment enrollment)
 {
     //Post data for enrollment
     return(string.Format("enrolments[0][roleid]={0}&enrolments[0][userid]={1}&enrolments[0][courseid]={2}", enrollment.RoleId, enrollment.UserId, enrollment.CourseId));
 }