Exemple #1
0
        public List <ArtistId> SelectAll()
        {
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "select * from artist_ids";

            SqlDataReader sqlDataReader = Db.Select(sqlCommand);

            List <ArtistId> listArtistIds = new List <ArtistId>();

            if (sqlDataReader.HasRows)
            {
                while (sqlDataReader.Read())
                {
                    ArtistId artistId = new ArtistId();
                    artistId.Id    = (Int32)sqlDataReader["id"];
                    artistId.Value = (String)sqlDataReader["usd"];
                    artistId.Card  = new CardDAO().SelectById((Int32)sqlDataReader["id_card"]);
                    listArtistIds.Add(artistId);
                }
                sqlDataReader.Read();

                return(listArtistIds);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        public ArtistId SelectById(Int32 id)
        {
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "select * from artist_ids where id = @id";

            sqlCommand.Parameters.AddWithValue("@id", id);

            SqlDataReader sqlDataReader = Db.Select(sqlCommand);

            ArtistId artistId = new ArtistId();

            if (sqlDataReader.HasRows)
            {
                sqlDataReader.Read();
                artistId.Id    = (Int32)sqlDataReader["id"];
                artistId.Value = (String)sqlDataReader["usd"];
                artistId.Card  = new CardDAO().SelectById((Int32)sqlDataReader["id_card"]);

                return(artistId);
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        public void Delete(ArtistId artistId)
        {
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "delete from artist_ids where id = @id";

            sqlCommand.Parameters.AddWithValue("@id", artistId.Id);

            Db.Execute(sqlCommand);
        }
Exemple #4
0
        public void Insert(ArtistId artistId)
        {
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "insert into artist_ids (value, id_card) values (@value, @id_card)";

            sqlCommand.Parameters.AddWithValue("@value", artistId.Value);
            sqlCommand.Parameters.AddWithValue("@id_card", artistId.Card.Id);

            Db.Execute(sqlCommand);
        }
Exemple #5
0
        public void Update(ArtistId artistId)
        {
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "update artist_ids set value = @value, id_card = @id_card where id = @id";

            sqlCommand.Parameters.AddWithValue("@id", artistId.Id);
            sqlCommand.Parameters.AddWithValue("@value", artistId.Value);
            sqlCommand.Parameters.AddWithValue("@id_card", artistId.Card.Id);

            Db.Execute(sqlCommand);
        }