Esempio n. 1
0
        public async Task <IActionResult> GetMusic(string correlationToken, int id)
        {
            Guard.ForNullOrEmpty(correlationToken, "correlationToken");
            Guard.ForLessEqualZero(id, "albumId");

            var album = await _catalogBusinessServices.GetMusic(correlationToken, id);

            if (album == null)
            {
                return(new ObjectResult(album));
            }

            return(new ObjectResult(Mapper.MapToMusicDto(album)));
        }
        public async Task <IActionResult> GetMusic(int id, [FromHeader(Name = "x-correlationToken")]
                                                   string correlationToken)
        {
            if (string.IsNullOrEmpty(correlationToken))
            {
                return(BadRequest("CorrelationToken not present"));
            }

            Guard.ForNullOrEmpty(correlationToken, "correlationToken");
            Guard.ForLessEqualZero(id, "albumId");

            var product = await _catalogBusinessServices.GetMusic(correlationToken, id);

            return(product == null
                ? BadRequest("Product does not exist")
                : new ObjectResult(Mapper.MapToMusicDto(product)));
        }