public async Task <IActionResult> AddNewProduct(ProductViewModel productViewModel) { if (ModelState.IsValid) { if (productViewModel.ImageName != null) { var filePath = _hostingEnvironment.WebRootPath + "Images/"; var fileName = productViewModel.ImageName.FileName; string path = Path.Combine(filePath, fileName); productViewModel.ImageName.CopyTo(new FileStream(path, FileMode.Create)); productViewModel.ImageFile = productViewModel.ImageName.FileName; } await _productPageService.AddNewProduct(productViewModel); } else { } return(View()); }