示例#1
0
        public async Task <IActionResult> GetTopSellingMusic(string correlationToken, int count = _topSellingCount)
        {
            Guard.ForNullOrEmpty(correlationToken, "correlationToken");
            Guard.ForLessEqualZero(count, "count");

            var albums = await _catalogBusinessServices.GetTopSellingMusic(correlationToken, count);

            if (albums.Count < 1)
            {
                return(new ObjectResult(new List <MusicDto>()));
            }

            return(new ObjectResult(Mapper.MapToMusicDto(albums)));
        }
        public async Task <IActionResult> GetTopSellingMusic([FromHeader(Name = "x-correlationToken")]
                                                             string correlationToken, int count = TopSellingCount)
        {
            Guard.ForNullOrEmpty(correlationToken, "correlationToken");
            Guard.ForLessEqualZero(count, "count");

            var products = await _catalogBusinessServices.GetTopSellingMusic(correlationToken, count);

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

            return(new ObjectResult(Mapper.MapToMusicDto(products)));
        }