Example #1
0
        public async Task <IActionResult> GetAllGenres(string correlationToken, [FromQuery] bool includeAlbums)
        {
            Guard.ForNullOrEmpty(correlationToken, "correlationToken");

            var genres = await _catalogBusinessServices.GetAllGenres(correlationToken, includeAlbums);

            if (genres.Count < 1)
            {
                return(new ObjectResult(new List <GenreDto>()));
            }

            // ObjectResult return type is capable of content negotiation
            return(new ObjectResult(Mapper.MapToGenreDto(genres)));
        }
        public async Task <IActionResult> GetAllGenres([FromQuery] bool includeAlbums,
                                                       [FromHeader(Name = "x-correlationToken")]
                                                       string correlationToken)
        {
            Guard.ForNullOrEmpty(correlationToken, "correlationToken");

            var genres = await _catalogBusinessServices.GetAllGenres(correlationToken, includeAlbums);

            if (genres == null || genres.Count < 1)
            {
                return(BadRequest("Genres do not exist"));
            }

            return(new ObjectResult(Mapper.MapToGenreDto(genres)));
        }