Esempio n. 1
0
 public override bool Equals(System.Object otherCourse)
 {
     if (!(otherCourse is Course))
     {
         return(false);
     }
     else
     {
         Course newCourse            = (Course)otherCourse;
         bool   courseNameEquality   = (this.GetCourseName() == newCourse.GetCourseName());
         bool   courseNumberEquality = (this.GetCourseId() == newCourse.GetCourseId());
         bool   courseIdEquality     = (this.GetCourseId() == newCourse.GetCourseId());
         return(courseNameEquality && courseNumberEquality && courseIdEquality);
     }
 }
Esempio n. 2
0
        public void AddCourse(Course newCourse)
        {
            MySqlConnection conn = DB.Connection();

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

            cmd.CommandText = @"INSERT INTO enrollments (students_id, courses_id) VALUES (@StudentsId, @CoursesId);";

            MySqlParameter students_id = new MySqlParameter();

            students_id.ParameterName = "@StudentsId";
            students_id.Value         = _studentId;
            cmd.Parameters.Add(students_id);

            MySqlParameter courses_id = new MySqlParameter();

            courses_id.ParameterName = "@CoursesId";
            courses_id.Value         = newCourse.GetCourseId();
            cmd.Parameters.Add(courses_id);

            cmd.ExecuteNonQuery();
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
        }
Esempio n. 3
0
 public override bool Equals(System.Object otherCourse)
 {
     if (!(otherCourse is Course))
     {
         return(false);
     }
     else
     {
         Course newCourse    = (Course)otherCourse;
         bool   idEquality   = this.GetCourseId().Equals(newCourse.GetCourseId());
         bool   nameEquality = this._courseName.Equals(newCourse._courseName);
         return(idEquality && nameEquality);
     }
 }