示例#1
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);
     }
 }
示例#2
0
        public static Shadow Find(int id)
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand   cmd = new SqlCommand("SELECT * FROM shadows WHERE id = @ShadowId", conn);
            SqlParameter shadowIdParameter = new SqlParameter();

            shadowIdParameter.ParameterName = "@ShadowId";
            shadowIdParameter.Value         = id.ToString();
            cmd.Parameters.Add(shadowIdParameter);
            SqlDataReader rdr = cmd.ExecuteReader();

            int    foundShadowId    = 0;
            string foundShadowName  = null;
            string foundShadowType  = null;
            string foundShadowIntro = null;
            string foundShadowImg   = null;

            while (rdr.Read())
            {
                foundShadowId    = rdr.GetInt32(0);
                foundShadowName  = rdr.GetString(1);
                foundShadowType  = rdr.GetString(2);
                foundShadowIntro = rdr.GetString(3);
                foundShadowImg   = rdr.GetString(4);
            }
            Shadow foundShadow = new Shadow(foundShadowName, foundShadowType, foundShadowIntro, foundShadowImg, foundShadowId);

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

            return(foundShadow);
        }
示例#3
0
        public List <Shadow> GetShadows()
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand   cmd = new SqlCommand("SELECT shadows.* FROM answers JOIN shadows_answers ON (answers.id = shadows_answers.answer_id) JOIN shadows ON (shadows_answers.shadow_id = shadows.id) WHERE answers.id = @AnswerId;", conn);
            SqlParameter answerIdParameter = new SqlParameter();

            answerIdParameter.ParameterName = "@AnswerId";
            answerIdParameter.Value         = this.GetId();

            cmd.Parameters.Add(answerIdParameter);

            SqlDataReader rdr = cmd.ExecuteReader();

            List <Shadow> shadows = new List <Shadow> {
            };

            while (rdr.Read())
            {
                int    shadowId    = rdr.GetInt32(0);
                string shadowName  = rdr.GetString(1);
                string shadowType  = rdr.GetString(2);
                string shadowIntro = rdr.GetString(3);
                string shadowImg   = rdr.GetString(4);
                Shadow foundShadow = new Shadow(shadowName, shadowType, shadowIntro, shadowImg, shadowId);
                shadows.Add(foundShadow);
            }
            if (rdr != null)
            {
                rdr.Close();
            }

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