public async Task <IActionResult> Edit(PetViewModel model) { if (ModelState.IsValid) { try { var path = model.ImageUrl; if (model.ImageFile != null && model.ImageFile.Length > 0) { path = await _imageHelper.UploadImageAsync(model.ImageFile, "Pets"); } var pet = _converterHelper.ToPet(model, path, false); pet.ModifiedBy = await _userHelper.GetUserByEmailAsync(User.Identity.Name); await _petRepository.UpdateAsync(pet); } catch (DbUpdateConcurrencyException) { if (!await _petRepository.ExistAsync(model.Id)) { return(new NotFoundViewResult("PetNotFound")); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(model)); }