public GetAlbumsOrTracksResult GetAlbumsOrTracks(GetAlbumsOrTracksRequest 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.FindAlbumsOrTracks(request.Filter, request.SortBy, forPlaylistId, request.Offset, request.Size); totalCount = mgr.FindAlbumsOrTracksCount(request.Filter, forPlaylistId); } // set the cover urls foreach (var item in albumOrTracks) { item.ArtImage = item.CoverId > 0 ? Url.Action("GetCover", new { id = item.CoverId }) : ""; } return(new GetAlbumsOrTracksResult() { Success = true, Items = albumOrTracks.ToArray(), TotalCount = totalCount }); } catch (Exception ex) { return(GetErrorResultFromException <GetAlbumsOrTracksResult>(ex)); } }