Пример #1
0
        public string EditSong(string form, string fileStream, string fileName, string fileType)
        {
            var result = "The song was not uploaded. Please try again. If the problem persists, please contact us at [email protected]";
            var formCollection = form.Split('&');
            var trmservice = new WebService.WCFWebServiceJson();
            var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);
            var util = new Utilities();
            var localFile = Path.Combine(MusicManagerBase.LocalTempDestinationPath, fileName);

            if (!string.IsNullOrEmpty(fileStream))
            {
                byte[] bytes = Convert.FromBase64String(fileStream);
                using (MemoryStream ms = new MemoryStream(bytes))
                {
                    using (FileStream file = new FileStream(localFile, FileMode.Create, System.IO.FileAccess.Write))
                    {
                        ms.Read(bytes, 0, (int)ms.Length);
                        file.Write(bytes, 0, bytes.Length);
                        ms.Close();
                    }
                }
            }

            if (!string.IsNullOrEmpty(fileName) || !string.IsNullOrEmpty(MusicManagerBase.ReturnFormItemValue(formCollection, "MediaAssetPath")))
            {
                // Attempt to save the song
                try
                {
                    var albumCollection = new List<Album>();
                    var songGenreList = new List<Genre>();

                    foreach (var formItem in formCollection)
                    {
                        if (formItem.ToString().StartsWith("genre"))
                        {
                            songGenreList.Add(new Genre
                            {
                                GenreId = GetGenreId(formItem.ToString()),
                                GenreName = GetGenreName(formItem.ToString())
                            });
                        }
                    }

                    var albumId = 0;
                    if (!string.IsNullOrEmpty(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumId")) && Convert.ToInt32(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumId")) > 0)
                    {
                        albumId = Convert.ToInt32(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumId"));
                    }

                    var songId = 0;
                    if (!string.IsNullOrEmpty(MusicManagerBase.ReturnFormItemValue(formCollection, "SongId")) && Convert.ToInt32(MusicManagerBase.ReturnFormItemValue(formCollection, "SongId")) > 0)
                    {
                        songId = Convert.ToInt32(MusicManagerBase.ReturnFormItemValue(formCollection, "SongId"));
                    }

                    var album = trmservice.GetArtistAlbumDetails(albumId);
                    albumCollection.Add(album);

                    var mediaFileFolder = string.Empty;
                    var mediaFileLocation = string.Empty;

                    if (!string.IsNullOrEmpty(fileName))
                    {
                        mediaFileLocation = localFile;
                        mediaFileFolder = util.RemoveSpaces(artist.ArtistName) + "/" + util.RemoveSpaces(album.AlbumTitle) + "/";
                    }

                    var releaseDate = MusicManagerBase.ReturnFormItemValue(formCollection, "SongReleaseDate").ToString().Replace("%2F", "/");

                    var song = new Song()
                    {
                        AlbumCollection = albumCollection,
                        CreatedDate = DateTime.Now,
                        GenreCollection = songGenreList,
                        SongComposer = MusicManagerBase.ReturnFormItemValue(formCollection, "SongComposer"),
                        SongId = songId,
                        SongReleaseDate = Convert.ToDateTime(releaseDate),
                        SongTitle = MusicManagerBase.ReturnFormItemValue(formCollection, "SongTitle"),
                        PRS = MusicManagerBase.ReturnFormBooleanValue(formCollection, "PRS")
                    };

                    // upload and save the song
                    if (trmservice.UploadSong(song, mediaFileLocation, "mp3", mediaFileFolder))
                    {
                        result = "The song \"" + song.SongTitle + "\" has been uploaded successfully.";
                    }
                }
                catch (MembershipCreateUserException e)
                {
                    result = ErrorCodeToString(e.StatusCode);
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
            }
            else
            {
                result = "Please select a media file to upload";
            }

            return result;
        }
Пример #2
0
        public string DeleteSong(int songId, int albumId)
        {
            var result = "There was a problem deleting this song. Please try again. If the problem persists, please contact [email protected]";

            try
            {
                var trmservice = new WebService.WCFWebServiceJson();
                var album = trmservice.GetArtistAlbumDetails(albumId);
                var song = trmservice.GetArtistSongDetails(songId);

                trmservice.DeleteSong(song, album);
                result = "The song " + song.SongTitle + "has been successfully removed from the album " + album.AlbumTitle + ".";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return result;
        }
Пример #3
0
        public ActionResult EditAlbum(int albumId)
        {
            var artistAlbumModel = new ArtistAlbumModel();

            if (albumId > 0)
            {
                var trmservice = new WebService.WCFWebServiceJson();
                var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);
                var albumDetails = trmservice.GetArtistAlbumDetails(albumId);

                artistAlbumModel.AlbumId = albumDetails.AlbumId;
                artistAlbumModel.AlbumCoverPath = albumDetails.AlbumCover;
                artistAlbumModel.AlbumLabel = albumDetails.AlbumLabel;
                artistAlbumModel.AlbumProducer = albumDetails.AlbumProducer;
                artistAlbumModel.AlbumReleaseDate = albumDetails.AlbumReleaseDate;
                artistAlbumModel.AlbumTitle = albumDetails.AlbumTitle;
                artistAlbumModel.GenreCollection = albumDetails.GenreCollection;
            }

            return View(artistAlbumModel);
        }
Пример #4
0
        public string DeleteAlbum(int albumId)
        {
            var result = "There was a problem deleting this album. Please try again. If the problem persists, please contact [email protected]";

            try
            {
                var trmservice = new WebService.WCFWebServiceJson();
                var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);
                var album = trmservice.GetArtistAlbumDetails(albumId);

                trmservice.DeleteArtistAlbum(album, artist);
                result = "The album " + album.AlbumTitle + " has been successfully removed.";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return result;
        }