public static List <Beanie> GetAll()
        {
            List <Beanie> allBabies = new List <Beanie> {
            };

            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand    cmd = new SqlCommand("SELECT * FROM beanie_babies;", conn);
            SqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                int    beanieId     = rdr.GetInt32(0);
                string beanieName   = rdr.GetString(1);
                string beanieRarity = rdr.GetString(2);
                int    beanieCost   = rdr.GetInt32(3);
                Beanie newBeanie    = new Beanie(beanieName, beanieRarity, beanieCost, beanieId);
                allBabies.Add(newBeanie);
            }

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

            return(allBabies);
        }
 public override bool Equals(System.Object otherBeanie)
 {
     if (!(otherBeanie is Beanie))
     {
         return(false);
     }
     else
     {
         Beanie newBeanie    = (Beanie)otherBeanie;
         bool   nameEquality = (this.GetName() == newBeanie.GetName());
         return(nameEquality);
     }
 }
        public static Beanie Find(int id)
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand   cmd = new SqlCommand("SELECT * FROM beanie_babies WHERE id = @BeanieId;", conn);
            SqlParameter beanieIdParameter = new SqlParameter();

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

            int    foundBeanieId     = 0;
            int    foundBeanieCost   = 0;
            string foundBeanieName   = null;
            string foundBeanieRarity = null;

            while (rdr.Read())
            {
                foundBeanieId     = rdr.GetInt32(0);
                foundBeanieName   = rdr.GetString(1);
                foundBeanieRarity = rdr.GetString(2);
                foundBeanieCost   = rdr.GetInt32(3);
            }
            Beanie foundBeanie = new Beanie(foundBeanieName, foundBeanieRarity, foundBeanieCost, foundBeanieId);

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

            return(foundBeanie);
        }