public async Task <IActionResult> Edit(DoctorViewModel model) { if (ModelState.IsValid) { try { var path = model.ImageUrl; if (model.ImageFile != null && model.ImageFile.Length > 0) { path = await _imageHelper.UploadImageAsync(model.ImageFile, "Doctors"); } var doctor = _converterHelper.ToDoctor(model, path, false); doctor.User = await _userHelper.GetUserByEmailAsync(this.User.Identity.Name); await _doctorRepository.UpdateAsync(doctor); } catch (DbUpdateConcurrencyException) { if (!await _doctorRepository.ExistsAsync(model.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } model.Specialities = _combosHelper.GetComboSpecialities(); return(View(model)); }