コード例 #1
0
ファイル: Specialty.cs プロジェクト: Colton141/HairSalon-1
        public void DeleteSpecialty(int specialtyId)
        {
            MySqlConnection conn = DB.Connection();

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

            Specialty selectedSpecialty       = Specialty.Find(specialtyId);
            Dictionary <string, object> model = new Dictionary <string, object>();
            List <Stylist> stylistSpecialty   = selectedSpecialty.GetStylists();

            model.Add("specialty", selectedSpecialty);

            foreach (Stylist stylist in stylistSpecialty)
            {
                stylist.Delete();
            }

            cmd.CommandText = @"DELETE FROM specialties WHERE id = @thisId;";
            cmd.Parameters.AddWithValue("@thisId", _id);
            cmd.ExecuteNonQuery();

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