public static List <Wine> GetAll()
        {
            List <Wine> allWines = new List <Wine> {
            };
            MySqlConnection conn = DB.Connection();

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

            cmd.CommandText = @"SELECT * FROM wines;";
            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                int    itemId      = rdr.GetInt32(0);
                string itemWine    = rdr.GetString(1);
                string itemYachtId = rdr.GetString(2);
                Wine   newWine     = new Wine(itemWine, itemYachtId, itemId);
                allWines.Add(newWine);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(allWines);
        }
 public override bool Equals(System.Object otherWine)
 {
     if (!(otherWine is Wine))
     {
         return(false);
     }
     else
     {
         Wine newWine       = (Wine)otherWine;
         bool idEquality    = (this.GetId() == newWine.GetId());
         bool yachtEquality = (this.GetWine() == newWine.GetWine());
         return(idEquality && yachtEquality);
     }
 }
        public static Wine Find(int id)
        {
            MySqlConnection conn = DB.Connection();

            conn.Open();

            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM `wines` WHERE id = @thisId;";

            MySqlParameter thisId = new MySqlParameter();

            thisId.ParameterName = "@thisId";
            thisId.Value         = id;
            cmd.Parameters.Add(thisId);

            var rdr = cmd.ExecuteReader() as MySqlDataReader;

            int    itemId      = 0;
            string itemWine    = "";
            string itemYachtId = "";

            while (rdr.Read())
            {
                itemId      = rdr.GetInt32(0);
                itemWine    = rdr.GetString(1);
                itemYachtId = rdr.GetString(2);
            }

            Wine foundWine = new Wine(itemWine, itemYachtId, itemId);

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

            return(foundWine);
        }