Exemplo n.º 1
0
        public Album SaveItem(Album album)
        {
            SqlParameter[] parameter =
            {
                new SqlParameter("title",  SqlDbType.VarChar, 50)
                {
                    Value = album.Title
                },
                new SqlParameter("artist", SqlDbType.VarChar, 50)
                {
                    Value = album.Artist
                }
            };
            var sqlInsertAlbum = $"INSERT INTO albums (title, artist) VALUES (\"{parameter[0].Value}\", \"{parameter[1].Value}\" )";
            RepoInterface <Album> repoInterface = this;
            int id = repoInterface.InsertIntoDB(sqlInsertAlbum);

            album.AlbumId = id;

            if (album.SongList != null)
            {
                foreach (Song song in album.SongList)
                {
                    song.AlbumId = album.AlbumId;
                    _songRepo.SaveItem(song);
                }
            }
            return(album);
        }
Exemplo n.º 2
0
        public Song CreateNewItem(Song song)
        {
            var savedSong = _songRepo.SaveItem(song);

            return(savedSong);
        }