public async Task <IActionResult> Edit(Patient patient) { if (ModelState.IsValid) { if (int.TryParse(User.FindFirstValue("id"), out int id)) { var res = (await _patientRepository.GetWithInclude(p => p.Id == id)).FirstOrDefault(); var belay = await _belayRepository.GetById(patient.Belay.Id); patient.PasswordHash = res.PasswordHash; patient.CreateDate = res.CreateDate; patient.Belay = belay; var user = await _patientRepository.Update(id, patient); _notificationService.AddSuccess("Данные успешно сохранены"); _notificationService.ApplyForRedirect(TempData); await HttpContext.SignOutAsync(); await SignIn(user); } return(RedirectToAction("Index")); } else { ViewBag.BelaysList = await GetBelaysSelectList(patient.Belay.Id); return(View(patient)); } }