Example #1
0
        public Album GetItemById(int id)
        {
            SqlParameter parameter = new SqlParameter("id", SqlDbType.Int, 50)
            {
                Value = id
            };
            var sqlSelectAlbum = $"SELECT * FROM albums WHERE id = {parameter.Value}";
            RepoInterface <Album> repoInterface = this;
            var res = repoInterface.QueryDB(sqlSelectAlbum);

            if (res.Rows.Count > 0)
            {
                var rawCol   = res.Rows[0].ItemArray;
                var alId     = Convert.ToInt32(rawCol[0]);
                var alTitle  = rawCol[1].ToString();
                var alArtist = rawCol[2].ToString();
                var songList = _songRepo.GetSongsFromAl(alId);
                return(new Album(songList, alId, alTitle, alArtist));
            }
            return(null);
        }