public void AddSpecialty(Specialty newSpecialty) { MySqlConnection conn = DB.Connection(); conn.Open(); var cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"INSERT INTO doctors_specialties (doctor_id, specialty_id) VALUES (@DoctorId, @SpecialtyId);"; MySqlParameter doctor_id = new MySqlParameter(); doctor_id.ParameterName = "@DoctorId"; doctor_id.Value = _id; cmd.Parameters.Add(doctor_id); MySqlParameter specialty_id = new MySqlParameter(); specialty_id.ParameterName = "@SpecialtyId"; specialty_id.Value = newSpecialty.GetId(); cmd.Parameters.Add(specialty_id); cmd.ExecuteNonQuery(); conn.Close(); if (conn != null) { conn.Dispose(); } }
public override bool Equals(System.Object otherSpecialty) { if (!(otherSpecialty is Specialty)) { return(false); } else { Specialty newSpecialty = (Specialty)otherSpecialty; return(this.GetId().Equals(newSpecialty.GetId())); } }
public override bool Equals(System.Object otherSpecialty) { if (!(otherSpecialty is Specialty)) { return(false); } else { Specialty newSpecialty = (Specialty)otherSpecialty; bool idEquality = this.GetId().Equals(newSpecialty.GetId()); bool nameEquality = this.GetName().Equals(newSpecialty.GetName()); return(idEquality && nameEquality); } }