コード例 #1
0
        public async Task <IActionResult> GetArtists([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 artists = await _artistsService.GetArtistsAsync(pagingOptions, cancellationToken);

            var link       = Link.CreateCollection(nameof(GetArtists), null);
            var collection = PagedCollection <ArtistResource> .CreatePagedCollection(link, artists.Items, artists.TotalSize, pagingOptions);

            return(Ok(collection));
        }
コード例 #2
0
        public List <ArtistModel> GetArtists([FromBody] ArtistsPageFilter filter)
        {
            var artists = _artistsService.GetArtistsAsync(filter);

            return(artists.Result);
        }