Exemplo n.º 1
0
        public bool DeleteAlbum(Album album)
        {
            try
            {
                albumTable.DeleteOnSubmit(album);
                albumTable.Context.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }
Exemplo n.º 2
0
        private void btnUploadAlbum_Click(object sender, EventArgs e)
        {
            ClearAlbumsResultTextBoxes();

            var artist = WCFWebServiceJson.GetArtist(Convert.ToInt32(TxtAlbumWordpressId.Text));
            var albumGenreCollection = (from ListItem listItem in lbAlbumGenres.SelectedItems select WCFWebServiceJson.GetGenre(listItem.SelectedValue())).ToList();

            var album = new Album()
            {
                AlbumLabel = txtAlbumLabel.Text,
                AlbumProducer = txtAlbumProducer.Text,
                AlbumReleaseDate = Convert.ToDateTime(dtpAlbumReleaseDate.Text),
                AlbumTitle = txtAlbumTitle.Text,
                CreatedDate = DateTime.Now,
                GenreCollection = albumGenreCollection
            };

            if (WCFWebServiceJson.SaveArtistAlbum(album, artist, null))
            {
                txtAlbumResult.Text = album.AlbumTitle + @" has been saved successfully!";
            }
            else
            {
                txtAlbumResult.Text = @"There was a problem saving the album: " + album.AlbumTitle;
            }
        }
Exemplo n.º 3
0
        public int SaveAlbum(Album album)
        {
            try
            {
                if (album.AlbumId == 0)
                {
                    albumTable.InsertOnSubmit(album);
                }
                else
                {
                    albumTable.Context.Refresh(RefreshMode.KeepCurrentValues, album);
                }

                albumTable.Context.SubmitChanges();

                return album.AlbumId;
            }
            catch
            {
                return -1;
            }
        }
Exemplo n.º 4
0
 public bool DeleteSong(Song song, Album album)
 {
     using (var tranScope = new TransactionScope())
     {
         try
         {
             if (DeleteAlbumSong(song, album))
             {
                 var songMediaAsset = SqlSongMediaAssetRepository.SongMediaAsset.FirstOrDefault(x => x.SongId == song.SongId);
                 if (SqlSongMediaAssetRepository.DeleteSongMediaAsset(songMediaAsset))
                 {
                     if (SqlMediaAssetRepository.DeleteMediaAsset(SqlMediaAssetRepository.MediaAsset.FirstOrDefault(x => x.MediaAssetId == songMediaAsset.MediaAssetId)))
                     {
                         if (SqlSongRepository.DeleteSong(song))
                         {
                             tranScope.Complete();
                             return true;
                         }
                         else
                         {
                             return false;
                         }
                     }
                     else
                     {
                         return false;
                     }
                 }
                 else
                 {
                     return false;
                 }
             }
             else
             {
                 return false;
             }
         }
         catch
         {
             return false;
         }
     }
 }
Exemplo n.º 5
0
        public bool DeleteArtistAlbum(Album album, Artist artist)
        {
            using (var tranScope = new TransactionScope())
            {
                var artistAlbum =
                    SqlArtistAlbumRepository.ArtistAlbum.FirstOrDefault(
                        x => x.AlbumId == album.AlbumId && x.UserId == artist.UserId);

                try
                {
                    if (SqlArtistAlbumRepository.DeleteArtistAlbum(artistAlbum))
                    {
                        if (SqlAlbumRepository.DeleteAlbum(album))
                        {
                            tranScope.Complete();
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else
                    {
                        return false;
                    }
                }
                catch
                {
                    return false;
                }
            }
        }
Exemplo n.º 6
0
        public bool DeleteAlbumSong(Song song, Album album)
        {
            var albumSong =
                SqlAlbumSongRepository.AlbumSong.FirstOrDefault(
                    x => x.SongId == song.SongId && x.AlbumId == album.AlbumId);

            return SqlAlbumSongRepository.DeleteAlbumSong(albumSong);
        }
Exemplo n.º 7
0
        public bool SaveArtistAlbum(Album album, Artist artist, string sourceFile)
        {
            using (var tranScope = new TransactionScope())
            {
                try
                {
                    var albumId = SqlAlbumRepository.SaveAlbum(album);

                    if (albumId > 0)
                    {
                        if (SaveAlbumGenreCollection(albumId, album.GenreCollection))
                        {
                            var util = new Utilities();
                            var artistAlbum = new ArtistAlbum()
                                 {
                                     AlbumId = albumId,
                                     UserId = artist.UserId
                                 };

                            if (UploadFileToS3(sourceFile, util.RemoveSpaces(artist.ArtistName) + "/" + util.RemoveSpaces(album.AlbumTitle) + "/", "stream"))
                            {
                                if (SqlArtistAlbumRepository.SaveArtistAlbum(artistAlbum))
                                {
                                    tranScope.Complete();
                                    return true;
                                }
                            }
                        }
                    }
                }
                catch
                {
                    return false;
                }
            }

            return false;
        }