コード例 #1
0
 public ActionResult <ProductImage> Post([FromBody] ProductImage ProductImage)
 {
     if (string.IsNullOrEmpty(ProductImage.url))
     {
         return(BadRequest("url required."));
     }
     _ProductImageService.Create(ProductImage);
     return(Ok("ProductImage successfully created."));
 }
コード例 #2
0
        public async Task <IActionResult> AddProductImage(int productId, [FromForm] ProductImageRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _productImageService.Create(productId, request);

            if (!result.IsSuccessed)
            {
                return(BadRequest(result.Message));
            }
            return(Ok());
        }
コード例 #3
0
        public ActionResult <ProductImage> PostProductImage(ProductImage productImage)
        {
            try
            {
                productImageService.Create(productImage);
            }
            catch (DbUpdateException)
            {
                if (ProductImageExists(productImage.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetProductImage", new { id = productImage.Id }, productImage));
        }