public async Task <IActionResult> GetArtistAlbums([FromRoute] int id, [FromQuery] PagingOptions pagingOptions, CancellationToken cancellationToken) { if (!ModelState.IsValid) { return(BadRequest(new ApiError() { Message = "Invalid arguments provided.", Details = ModelState.FirstOrDefault(k => k.Value.Errors.Any()).Value.Errors.FirstOrDefault().ErrorMessage })); } pagingOptions.Limit = pagingOptions.Limit ?? _defaultPagingOptions.Limit; pagingOptions.Offset = pagingOptions.Offset ?? _defaultPagingOptions.Offset; var albums = await _albumsService.GetAlbumsForArtistAsync(id, pagingOptions, cancellationToken); var link = Link.CreateCollection(nameof(GetArtistAlbums), null); var collection = PagedCollection <AlbumResource> .CreatePagedCollection(link, albums.Items, albums.TotalSize, pagingOptions); return(Ok(collection)); }