public async Task <IActionResult> GetImageById(int productId, int imageId)
        {
            var image = await _manageProductService.GetImageById(imageId);

            if (image == null)
            {
                return(BadRequest("Cannot find product"));
            }
            return(Ok(image));
        }
Esempio n. 2
0
        public async Task <IActionResult> CreateImage(int productId, [FromForm] ProductImageCreateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var imageId = await _manageProductService.AddImages(productId, request);

            if (imageId == 0)
            {
                return(BadRequest());
            }
            var image = await _manageProductService.GetImageById(imageId);

            return(CreatedAtAction(nameof(GetImageById), new { id = imageId }));
        }