public ActionResult <ProductImage> Post([FromBody] ProductImage ProductImage) { if (string.IsNullOrEmpty(ProductImage.url)) { return(BadRequest("url required.")); } _ProductImageService.Create(ProductImage); return(Ok("ProductImage successfully created.")); }
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()); }
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)); }