public GetTracksResult GetTracks(GetTracksRequest request) { try { int forPlaylistId; if (string.IsNullOrEmpty(request.ForPlaylistId)) { // no playlist filtering forPlaylistId = Domain.Objects.Playlist.ALL_ID; } else { forPlaylistId = int.Parse(request.ForPlaylistId); } List <AlbumOrTrackItem> albumOrTracks; int totalCount; using (DAL.DALManager mgr = new DAL.DALManager(settings.Value.DatabasePath)) { albumOrTracks = mgr.FindTracks(request.Filter, forPlaylistId, int.Parse(request.AlbumId), request.Offset, request.Size); totalCount = mgr.FindTracksCount(request.Filter, forPlaylistId, int.Parse(request.AlbumId)); } // set the cover urls foreach (var item in albumOrTracks) { item.ArtImage = item.CoverId > 0 ? Url.Action("GetCover", new { id = item.CoverId }) : ""; } return(new GetTracksResult() { Success = true, Items = albumOrTracks.ToArray(), TotalCount = totalCount }); } catch (Exception ex) { return(GetErrorResultFromException <GetTracksResult>(ex)); } }