public bool DeleteArtistGenre(ArtistGenre userGenre)
        {
            try
            {
                UserGenreTable.DeleteOnSubmit(userGenre);
                UserGenreTable.Context.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool SaveArtistGenre(ArtistGenre userGenre)
        {
            try
            {
                if (userGenre.ArtistGenreId == 0)
                {
                    UserGenreTable.InsertOnSubmit(userGenre);
                }
                else
                {
                    UserGenreTable.Context.Refresh(RefreshMode.KeepCurrentValues, userGenre);
                }

                UserGenreTable.Context.SubmitChanges();

                return true;
            }
            catch(Exception ex)
            {
                util.ErrorNotification(ex);
                throw;
            }
        }
Ejemplo n.º 3
0
        public bool UpdateArtistGenreCollection(int userId, List<Genre> genreCollection)
        {
            var isUpdated = true;

            // start by deleting all the genres before inserting the new list of genres that should contain the current ones
            var deleteGenreCollection = SqlArtistGenreRepository.DeleteAllArtistGenreByArtist(userId);

            if (deleteGenreCollection)
            {
                foreach (var genre in genreCollection)
                {
                    var artistGenre = new ArtistGenre()
                    {
                        UserId = userId,
                        GenreId = genre.GenreId
                    };

                    if (!SqlArtistGenreRepository.SaveArtistGenre(artistGenre))
                    {
                        return false;
                    }
                }
            }
            else
            {
                isUpdated = false;
            }

            return isUpdated;
        }