Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="albumYear"></param>
        /// <param name="artistId"></param>
        /// <param name="albumTitle"></param>
        /// <param name="albumRating"></param>
        /// <param name="genreId"></param>
        /// <returns></returns>
        public static int AddAlbum(int albumYear, int artistId, string albumTitle, int albumRating, int genreId)
        {
            var album = new CDCatalogEF.Album();

            try
            {
                album.AlbumYear   = albumYear;
                album.ArtistID    = artistId;
                album.AlbumTitle  = albumTitle;
                album.AlbumRating = albumRating;
                album.GenreID     = genreId;

                using (var db = new CDCatalogEntities())
                {
                    db.Albums.Add(album);
                    var resultCount = db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                // Define a new top-level error message.
                string str = "Adding the Album failed. " + ex.Message;

                // Pop-up a messagebox with the message
                MessageBox.Show(str);
            }
            var songId = album.ArtistID; // The song.ArtistID gets updated in the context as its saved

            return(artistId);
        }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="albumId"></param>
        /// <param name="albumYear"></param>
        /// <param name="artistId"></param>
        /// <param name="albumTitle"></param>
        /// <param name="albumRating"></param>
        /// <param name="genreId"></param>
        /// <returns></returns>
        public static bool ChangeAlbum(int albumId, int albumYear, int artistId, string albumTitle, int albumRating, int genreId)
        {
            var album = new CDCatalogEF.Album();

            try
            {
                album.AlbumID = albumId;
                album.AlbumYear = albumYear;
                album.ArtistID = artistId;
                album.AlbumTitle = albumTitle;
                album.AlbumRating = albumRating;
                album.GenreID = genreId;

                using (var db = new CDCatalogEntities())
                {
                    db.Albums.First(i => i.AlbumID == albumId);
                    int resultCount = db.SaveChanges();
                    return true;  // if there is an exception, this won't run
                }
            }
            catch (Exception ex)
            {
                // Define a new top-level error message.
                string str = "Changing the Album failed. " + ex.Message;

                // Pop-up a messagebox with the message
                MessageBox.Show(str);
            }
            var songId = album.ArtistID; // The song.ArtistID gets updated in the context as its saved
            return true;
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="albumId"></param>
        /// <param name="albumYear"></param>
        /// <param name="artistId"></param>
        /// <param name="albumTitle"></param>
        /// <param name="albumRating"></param>
        /// <param name="genreId"></param>
        /// <returns></returns>
        public static bool ChangeAlbum(int albumId, int albumYear, int artistId, string albumTitle, int albumRating, int genreId)
        {
            var album = new CDCatalogEF.Album();

            try
            {
                album.AlbumID     = albumId;
                album.AlbumYear   = albumYear;
                album.ArtistID    = artistId;
                album.AlbumTitle  = albumTitle;
                album.AlbumRating = albumRating;
                album.GenreID     = genreId;

                using (var db = new CDCatalogEntities())
                {
                    db.Albums.First(i => i.AlbumID == albumId);
                    int resultCount = db.SaveChanges();
                    return(true);  // if there is an exception, this won't run
                }
            }
            catch (Exception ex)
            {
                // Define a new top-level error message.
                string str = "Changing the Album failed. " + ex.Message;

                // Pop-up a messagebox with the message
                MessageBox.Show(str);
            }
            var songId = album.ArtistID; // The song.ArtistID gets updated in the context as its saved

            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="albumYear"></param>
        /// <param name="artistId"></param>
        /// <param name="albumTitle"></param>
        /// <param name="albumRating"></param>
        /// <param name="genreId"></param>
        /// <returns></returns>
        public static int AddAlbum(int albumYear, int artistId, string albumTitle, int albumRating, int genreId)
        {
            var album = new CDCatalogEF.Album();

            try
            {
                album.AlbumYear = albumYear;
                album.ArtistID = artistId;
                album.AlbumTitle = albumTitle;
                album.AlbumRating = albumRating;
                album.GenreID = genreId;

                using (var db = new CDCatalogEntities())
                {
                    db.Albums.Add(album);
                    var resultCount = db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                // Define a new top-level error message.
                string str = "Adding the Album failed. " + ex.Message;

                // Pop-up a messagebox with the message
                MessageBox.Show(str);
            }
            var songId = album.ArtistID; // The song.ArtistID gets updated in the context as its saved
            return artistId;
        }