public async Task <IActionResult> Edit(int id, [FromForm] PatientViewModel model) { if (ModelState.IsValid) { try { var patient = await _client.SendRequestAsync <Patient>(HttpMethod.Get, $"Patients/{id}"); model.UpdatePatient(ref patient); await _client.SendRequestWithBodyAsync <Patient>(HttpMethod.Put, $"Patients/{id}", patient); TempData["message"] = "Your changes has been saved."; return(RedirectToAction(nameof(PatientsController.Details), new { id })); } catch (HttpRequestException) { throw new ServerConnectionException(); } } else { return(View(model)); } }