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()); } }
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()); } }