コード例 #1
0
        public bool DeleteArtistGenre(ArtistGenre userGenre)
        {
            try
            {
                UserGenreTable.DeleteOnSubmit(userGenre);
                UserGenreTable.Context.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }
コード例 #2
0
        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;
            }
        }
コード例 #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;
        }