Ejemplo n.º 1
0
        public void AddCourse(Course newCourse)
        {
            MySqlConnection conn = DB.Connection();

            conn.Open();
            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"INSERT INTO courses_students (course_id, student_id) VALUES (@coursesId, @studentId);";

            MySqlParameter courses_id = new MySqlParameter();

            courses_id.ParameterName = "@studentId";
            courses_id.Value         = _id;
            cmd.Parameters.Add(courses_id);

            MySqlParameter course_id = new MySqlParameter();

            course_id.ParameterName = "@coursesId";
            course_id.Value         = newCourse.GetId();
            cmd.Parameters.Add(course_id);
            cmd.ExecuteNonQuery();
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
        }
Ejemplo n.º 2
0
 public override bool Equals(System.Object otherCourse)
 {
     if (!(otherCourse is Course))
     {
         return(false);
     }
     else
     {
         Course newCourse  = (Course)otherCourse;
         bool   idEquality = (this.GetId() == newCourse.GetId());
         bool   nameEq     = (this.GetCourseName() == newCourse.GetCourseName());
         bool   numberEq   = (this.GetCourseNumber() == newCourse.GetCourseNumber());
         return(idEquality && nameEq && numberEq);
     }
 }
Ejemplo n.º 3
0
 public override bool Equals(System.Object otherCourse)
 {
     if (!(otherCourse is Course))
     {
         return(false);
     }
     else
     {
         Course newCourse           = (Course)otherCourse;
         bool   idEquality          = this.GetId() == newCourse.GetId();
         bool   descriptionEquality = this.GetName() == newCourse.GetName();
         bool   NumberEquality      = this.GetNumber() == newCourse.GetNumber();
         // We no longer compare Students' CourseIds in a categoryEquality bool here.
         return(idEquality && descriptionEquality && NumberEquality);
     }
 }
Ejemplo n.º 4
0
        public void AddCourse(Course newCourse)
        {
            MySqlConnection conn = DB.Connection();

            conn.Open();
            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"INSERT INTO courses_students (student_id, course_id) VALUES (@CourseId, @StudentId);";

            cmd.Parameters.Add(new MySqlParameter("@StudentId", _id));
            cmd.Parameters.Add(new MySqlParameter("@CourseId", newCourse.GetId()));

            cmd.ExecuteNonQuery();
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
        }