public IActionResult EditImage(string id) { if (id == null) { return(this.RedirectToAction("Select", "Items", new { id, returnUrl = "EditImage" })); } var viewModel = new ItemEditImageViewModel { Id = id, }; return(this.View(viewModel)); }
public async Task <IActionResult> EditImage(ItemEditImageViewModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } string rootPath = this.hostEnvironment.WebRootPath; var imageArr = await ImageService.ConvertIFormFileToByteArray(input.Image); var imageName = await CloudinaryService.UploadAsync(this.cloudinary, imageArr, "Items", rootPath, false); await this.itemService.UpdateImageAsync(input.Id, imageName); return(this.RedirectToAction("Id", "Items", new { area = string.Empty, input.Id })); }