public ActionResult DeletePatient(string UserID, string PatientName) { var results = new Message(); try { MembershipUser user = Membership.GetUser(PatientName); if (user != null) { var checkdelete = Membership.DeleteUser(PatientName, true); if (checkdelete == true) { try { _patients.DeletePatient(UserID); _physicians.DeletePatient(UserID); _encountinfos.DeletePatient(UserID); _Vitals.DeletePatient(UserID); _Allergies.DeletePatient(UserID); _problems.DeletePatient(UserID); _medications.DeletePatient(UserID); _vaccinations.DeletePatient(UserID); _procedures.DeletePatient(UserID); _careplans.DeletePatient(UserID); _labresults.DeletePatient(UserID); _socialhistories.DeletePatient(UserID); _encountdiagnos.DeletePatient(UserID); _cogfuncstatus.DeletePatient(UserID); _reasonhospital.DeletePatient(UserID); _immunizations.DeletePatient(UserID); results.success = "Suceess: " + PatientName + "'s All Related Records has been Deleted From Portal."; } catch (Exception ex) { results.error = "Error: " + "Some Error Occured While Deleting Patient Record From Portal.May Be If Patient Record No Longer Available"; } } } else { results.attention = "Attention: " + PatientName + " Patient Already Deleted.Or No longer Exists."; } } catch (Exception ex) { results.error = "Error: " + "Some Error Occured While Deleting Patient Record From Portal.May Be If Patient Record No Longer Available"; } return(Json(results)); }