示例#1
0
        public void AddShadow(Shadow newShadow)
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand   cmd = new SqlCommand("INSERT INTO shadows_answers (shadow_id, answer_id) VALUES (@AnswerId, @ShadowId);", conn);
            SqlParameter shadowIdParameter = new SqlParameter();

            shadowIdParameter.ParameterName = "@ShadowId";
            shadowIdParameter.Value         = this.GetId();
            cmd.Parameters.Add(shadowIdParameter);

            SqlParameter answerIdParameter = new SqlParameter();

            answerIdParameter.ParameterName = "@AnswerId";
            answerIdParameter.Value         = newShadow.GetId();
            cmd.Parameters.Add(answerIdParameter);

            cmd.ExecuteNonQuery();

            if (conn != null)
            {
                conn.Close();
            }
        }
示例#2
0
 public override bool Equals(System.Object otherShadow)
 {
     if (!(otherShadow is Shadow))
     {
         return(false);
     }
     else
     {
         Shadow newShadow     = (Shadow)otherShadow;
         bool   idEquality    = (this.GetId() == newShadow.GetId());
         bool   nameEquality  = (this.GetShadowName() == newShadow.GetShadowName());
         bool   typeEqulity   = (this.GetShadowType() == newShadow.GetShadowType());
         bool   introEquality = (this.GetIntro() == newShadow.GetIntro());
         bool   imgEquality   = (this.GetImg() == newShadow.GetImg());
         return(idEquality && nameEquality && typeEqulity);
     }
 }