Esempio n. 1
0
        public async Task <IActionResult> GetProductMedium(Guid categoryId, Guid productId, [FromQuery] ProductMediaParameter parameter)
        {
            var productMediumInfo = await _productMediaService.GetMediumForProductAsync(productId,
                                                                                        parameter.Type,
                                                                                        trackChanges : false);

            var fileConvertedResult = new List <string>();

            if (productMediumInfo is not null)
            {
                foreach (var productMediaInfo in productMediumInfo)
                {
                    var fileResult = FileExtension.ConvertFileToBase64String(productMediaInfo, parameter.Type);
                    fileConvertedResult.Add(fileResult);
                }
            }

            if (fileConvertedResult is not null)
            {
                return(Ok(fileConvertedResult));
            }
            else
            {
                return(NotFound());
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> GetProductMedia(Guid productId, Guid mediaId, [FromQuery] ProductMediaParameter parameter)
        {
            var productMediaInfo = await _productMediaService.GetProductMediaAsync(productId, mediaId, false);

            if (productMediaInfo is not null)
            {
                var fileResult = FileExtension.ConvertFileToBase64String(productMediaInfo, parameter.Type);

                return(Ok(JsonConvert.SerializeObject(fileResult)));
            }

            return(NotFound());
        }