public async Task <ActionResult> Edit(int id, PatientPayloadViewModel model) { try { var result = await _patientHandler.UpdatePatient(model); return(RedirectToAction(nameof(Create))); } catch { return(RedirectToAction(nameof(Create))); } }
public async Task <bool> UpdatePatient(PatientPayloadViewModel patient) { HttpResponseMessage res = await _apiAccessor.GetHttpClient().PutAsJsonAsync <PatientPayloadViewModel>("Patient/update", patient); if (res.IsSuccessStatusCode) { var empResponse = res.Content.ReadAsStringAsync().Result; var newPatient = JsonConvert.DeserializeObject <PatientPayloadViewModel>(empResponse); return(true); } return(false); }
public ActionResult Edit(int id, PatientPayloadViewModel model) { try { var result = _patientHandler.UpdatePatient(model); if (result) { return(RedirectToAction(nameof(Create))); } return(View(model)); } catch { return(RedirectToAction(nameof(Create))); } }
public async Task <ActionResult> Create(PatientPayloadViewModel model) { if (ModelState.IsValid) { try { var result = await _patientHandler.AddPatient(model); return(RedirectToAction(nameof(Create))); } catch { return(View()); } } else { ModelState.AddModelError("Error", "Please enter all the required fields"); return(View(model)); } }
public dynamic UpdatePatient(PatientPayloadViewModel patient) { return(null); }