Ejemplo n.º 1
0
 public IActionResult Get()
 {
     try
     {
         PlaylistModel playlistModel = _playlistRepository.GetModel(_settings.Value.PlaylistPath);
         IEnumerable <SongViewModel> songViewModels = playlistModel.Songs.Select(t =>
         {
             var res = new SongViewModel();
             res.MapFromModel(t);
             return(res);
         });
         return(new OkObjectResult(songViewModels));
     }
     catch (FileNotFoundException e)
     {
         return(new NotFoundResult());
     }
 }
Ejemplo n.º 2
0
        public IActionResult GetSongInfoById(int id)
        {
            try
            {
                PlaylistModel playlistModel = _playlistRepository.GetModel(_settings.Value.PlaylistPath);
                SongModel     song          = _playlistRepository.GetSongById(playlistModel, id);

                if (song is null)
                {
                    return(new NotFoundResult());
                }

                var res = new SongViewModel();
                res.MapFromModel(song);
                return(new OkObjectResult(res));
            }
            catch (FileNotFoundException e)
            {
                return(new NotFoundResult());
            }
        }