public void EditSongTest()
        {
            _songService.EditSong(
                new SongDTO
            {
                ID      = _song3Id,
                AlbumId = _album2Id,
                Name    = "NumbEDIT",
                Genre   = Genre.Alternative,
                Added   = new DateTime(2016, 11, 1)
            }, _album2Id);
            var editedSong = _songService.GetSong(_song3Id);

            Assert.AreEqual("NumbEDIT", editedSong.Name);
            Assert.AreEqual(Genre.Alternative, editedSong.Genre);
            Assert.AreEqual(new DateTime(2016, 11, 1), editedSong.Added);
        }
Пример #2
0
        // POST
        protected override DriverResult Editor(SongPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            if (updater == null)
            {
                throw new ArgumentNullException("updater");
            }
            if (part == null)
            {
                throw new ArgumentNullException("part");
            }

            var model = new SongViewModel();

            updater.TryUpdateModel(model, Prefix, null, null);
            // updater.TryUpdateModel(part, Prefix, null, null);

            _songService.EditSong(part, model);

            return(Editor(part, shapeHelper));
        }
Пример #3
0
 public void EditSong(SongDTO songDTO)
 {
     songService.EditSong(songDTO, songDTO.AlbumID, songDTO.ReviewIDs);
 }
Пример #4
0
 /// <summary>
 /// Makes the song official
 /// </summary>
 /// <param name="song">songDTO</param>
 public void MakeOfficial(SongDTO songDTO)
 {
     songDTO.IsOfficial = true;
     songService.EditSong(songDTO, songDTO.AlbumID, songDTO.ReviewIDs);
 }
Пример #5
0
 public void EditSong(SongDTO songDto, int albumId, params int[] songReviewIds)
 {
     _songService.EditSong(songDto, albumId, songReviewIds);
 }
Пример #6
0
        private static void TestSongService()
        {
            List <int> list = new List <int>();

            songService   = Container.Resolve <ISongService>();
            clientService = Container.Resolve <IClientService>();

            //Create
            songService.CreateSong(new SongDTO
            {
                Name       = "Hit The Floor",
                AlbumID    = albumID,
                CreatorID  = clientID,
                Duration   = new TimeSpan(0, 0, 3, 30),
                IsOfficial = true,
            });
            songService.CreateSong(new SongDTO
            {
                Name       = "4 Words",
                AlbumID    = albumID,
                CreatorID  = clientID,
                Duration   = new TimeSpan(0, 0, 3, 43),
                IsOfficial = true,
            });
            songService.CreateSong(new SongDTO
            {
                Name       = "All These Things I Hate",
                AlbumID    = albumID,
                CreatorID  = clientID2,
                Duration   = new TimeSpan(0, 0, 3, 45),
                IsOfficial = true,
            });


            //GetSongIdByName
            songID = songService.GetSongIdByName("Hit The Floor");
            int wordsID = songService.GetSongIdByName("4 Words");

            songID2 = songService.GetSongIdByName("All These Things I Hate");
            list.Add(songID);
            list.Add(wordsID);
            list.Add(songID2);
            Console.WriteLine(list.Count() == 3 ? "ClientService - GetSongIdByName - OK" : "ClientService - GetSongIdByName - FAIL");

            //GetSongById
            SongDTO floor  = songService.GetSong(songID);
            SongDTO words4 = songService.GetSong(wordsID);
            SongDTO hate   = songService.GetSong(songID2);

            Console.WriteLine(floor.Name == "Hit The Floor" ? "SongService - GetSongById - OK" : "SongService - GetSongById - FAIL");

            albumService = Container.Resolve <IAlbumService>();

            //AddSong
            songService.AddSong(floor);
            songService.AddSong(words4);
            songService.AddSong(hate);
            AlbumDTO album = albumService.GetAlbum(albumID);

            Console.WriteLine(album.SongIDs.Contains(songID) ?
                              "SongService - AddSong - OK" : "SongService - AddSong - FAIL");

            //GetAlbumOfSong
            AlbumDTO album2 = songService.GetAlbumOfSong(songID);

            Console.WriteLine(album2.ID == albumID ?
                              "SongService - GetAlbumOfSong - OK" : "SongService - GetAlbumOfSong - FAIL");

            //TestAlbumServisGetAllSongs
            Console.WriteLine(album.SongIDs.Count() == 3 ?
                              "AlbumService - TestAlbumServisGetAllSongs - OK" : "AlbumService - TestAlbumServisGetAllSongs - FAIL");

            ////ListAllSongs
            //var songs = songService.ListAllSongs(new SongFilter { AlbumID = albumID }, 1);
            //Console.WriteLine(songs.TotalResultCount == 3 ? "SongService - TestListAllSongs - OK" : "SongService - TestListAllSongs - FAIL");

            //ListAllSongss02
            var songs2 = songService.ListAllSongs();

            Console.WriteLine(songs2.Count() == 3 ? "SongService - ListAllSongss02 - OK" : "SongService - ListAllSongss02 - FAIL");

            //EditSong
            words4.Name = "Four Words";
            songService.EditSong(words4, albumID, words4.ReviewIDs);
            SongDTO words4FromDB = songService.GetSong(words4.ID);

            Console.WriteLine(words4FromDB.Name == "Four Words" ? "SongService - TestEditSong - OK" : "SongService - TestEditSong - FAIL");

            //DeleteSong
            songService.DeleteSong(wordsID);
            try {
                SongDTO wordsFromDB = songService.GetSong(wordsID);
                Console.WriteLine("SongService - TestDeleteSong - FAIL");
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("SongService - TestDeleteSong - OK");
            }

            //GetCreator
            ClientDTO creator = genreService.GetCreator(floor.ID);

            Console.WriteLine(creator.ID == clientID ? "SongService - GetCreator - OK" : "SongService - GetCreator - FAIL");
        }