public async Task <ActionResult <Song> > CreateSong(SongCreateViewModel model)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var result = await _songService.AddSong(_mapper.Map <SongDTO>(model), user);

            return(result.Succeeded ? (ActionResult)Ok(result.Model) : BadRequest(result.Error));
        }
Exemple #2
0
        public IActionResult Create(CreateSongViewModel model)
        {
            MusicCore.Song songCore = _mapper.Map <MusicCore.Song>(model.song);
            songCore.songArtistID = model.song.songArtistID;
            songCore.songGenreID  = model.song.songGenreID;

            Boolean success = _songService.AddSong(songCore);

            return(RedirectToAction("Songs"));
        }
Exemple #3
0
        public IEnumerable <string> Get()
        {
            _songService.AddSong(new Models.Song
            {
                Title       = "Vientos del pueblo",
                Description = "Vientos del pueblo de Ebri Knight",
                Duration    = new TimeSpan(0, 3, 25)
            });

            return(new string[] { "value1", "value2" });
        }
Exemple #4
0
        public ActionResult Upload(UploadSongBindingModel model)
        {
            if (model.AudioFile.ContentType.Contains("audio") &&
                model.AudioFile.ContentLength > 0)
            {
                var    audioPath     = Server.MapPath("~/uploads/audio/");
                var    imagePath     = Server.MapPath("~/uploads/image/");
                string audioFileName = service.UploadAudioFile(model.AudioFile, audioPath);
                string coverFileName = service.UploadCoverFile(model.ImageFile, imagePath);

                service.AddSong(model, audioFileName, coverFileName);

                return(RedirectToAction("Index"));
            }

            ViewBag.Genres = service.GetAvailableGenres();
            return(View(model));
        }
 public void AddSong(SongDTO songDTO)
 {
     songService.AddSong(songDTO);
 }
Exemple #6
0
 public int Post(CreateSongRequest song, CancellationToken ct)
 {
     return(_songService.AddSong(song, ct));
 }
Exemple #7
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");
        }
Exemple #8
0
        public async Task <ActionResult <Song> > CreateSong(SongCreateViewModel model)
        {
            var result = await _songService.AddSong(_mapper.Map <SongDTO>(model));

            return(result.Succeeded ? (ActionResult)Ok(result.Model) : BadRequest(result.Error));
        }