public async Task <ActionResult <ProductModel> > AddImage(int id, IFormFile image) { if (image == null) { return(BadRequest()); } return(await this.ExecuteWithOkResponse(async() => await _productService.AddImage(id, image))); }
public ActionResult AddImage(AddImageViewModel model, HttpPostedFileBase image1) { if (image1 != null && (image1.ContentType.Equals("image/png") || image1.ContentType.Equals("image/gif") || image1.ContentType.Equals("image/jpg") || image1.ContentType.Equals("image/jpeg"))) { model.ByteImage = new byte[image1.InputStream.Length]; image1.InputStream.Read(model.ByteImage, 0, image1.ContentLength); _productService.AddImage(model); } return(RedirectToAction("Details", new { productId = model.ProductId })); }