public bool SaveArtistAlbum(ArtistAlbum userAlbum)
        {
            try
            {
                if (userAlbum.ArtistAlbumId == 0)
                {
                    artistAlbumTable.InsertOnSubmit(userAlbum);
                }
                else
                {
                    artistAlbumTable.Context.Refresh(RefreshMode.KeepCurrentValues, userAlbum);
                }

                artistAlbumTable.Context.SubmitChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }
Пример #2
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;
        }