public async Task <IActionResult> EditPatient(int?id, [Bind("ID,DiagnosisCategoryId,DiagnosisTypeId,Description")] PatientDiagnosis[] diagnoses, [Bind("ID,DrugId,StartDate,EndDate")] PatientDrug[] drugs, [Bind("ID, ActivityScore, SymptomScore, ImpactScore, TotalScore")] PatientSTGQuestionnaire[] sTGQuestionnaires, [Bind("ID, DateTaken, Value, ImmunoglobulinTypeId")] PatientImmunoglobulin[] patientImmunoglobulines, [Bind("ID, DateTaken, FindingId, RadiologyTypeId, ChestLocationId, ChestDistributionId, GradeId, TreatmentResponseId, Note")] PatientRadiologyFinding[] radiololgyFindings, [Bind("ID, PatientId, MedicalTrialId, PatientMedicalTrialStatusId, IdentifiedDate, ConsentedDate, RecruitedDate, Consented")] PatientMedicalTrial[] patientMedicalTrial, [Bind("ID, PatientId, DrugId, UnitOfMeasurementId, DateTaken, DateReceived, ResultValue, ComparisionCharacter")] PatientDrugLevel[] drugLevels, [Bind("ID, SurgeryId, PatientId, SurgeryDate, Note")] PatientSurgery[] surgeries, [Bind("ID, AllergyIntoleranceItemType, AllergyIntoleranceItemId, IntoleranceType, Severity, Note")] PatientAllergicIntoleranceItem[] allergies, [Bind("ID, PulmonaryFunctionTestId, Value, ResultValue, PatientId")] PatientPulmonaryFunctionTest[] pulmonaryFunctionTest, [Bind("ID, FirstSeenAtNAC, CPABand, ReferralDate, LastObservationPoint, InitialDrug, FollowUp3MonthsDrug, PatientId")] PatientNACDates patientNACDates, [Bind("ID, DateTaken, Weight, Height")] PatientMeasurement[] patientMeasurements, [Bind("ID, DateTaken, Score")] PatientMRCScore[] patientMRCScores, [Bind("ID, SmokingStatusId, PatientId, StartAge, StopAge, CigarettesPerDay, PacksPerYear, AlcolholUnits")] PatientSmokingDrinkingStatus patientSmokingDrinkingStatus, CaseReportFormResult[] caseReportFormResult) { if (id == null) { return(NotFound()); } Patient patientToUpdate = await _patientManager .FindPatientWithFirstLevelRelationsByIdAsync(id); _patientManager.UpdateDiagnoses(diagnoses, patientToUpdate); _patientManager.UpdateDrugs(drugs, patientToUpdate, Request); _patientManager.UpdateSGRQ(sTGQuestionnaires, patientToUpdate); _patientManager.UpdateImmunoglobines(patientImmunoglobulines, patientToUpdate); _patientManager.UpdatePatientRadiology(radiololgyFindings, patientToUpdate); _patientManager.UpdatePatientMedicalTrials(patientMedicalTrial, patientToUpdate); _patientManager.UpdatePatientDrugLevels(drugLevels, patientToUpdate); _patientManager.UpdatePatientSurgeries(surgeries, patientToUpdate); _patientManager.UpdatePatientAllergiesIntolerances(allergies, patientToUpdate, Request); _patientManager.UpdatePatientsPFTs(pulmonaryFunctionTest, patientToUpdate); _patientManager.UpdateNacDates(patientNACDates, patientToUpdate); _patientManager.UpdateWeightHeight(patientMeasurements, patientToUpdate); _patientManager.UpdateMRCScore(patientMRCScores, patientToUpdate); AddOrSkipSmokingStatus(patientToUpdate, patientSmokingDrinkingStatus); _caseReportFormManager.UpdateCaseReportFormsForPatient(caseReportFormResult, patientToUpdate); _context.Entry(patientToUpdate).State = EntityState.Modified; ModelState.Remove("FirstSeenAtNAC"); //TODO - FIX THIS HACK.. if (await TryUpdateModelAsync <Patient>(patientToUpdate, "", p => p.FirstName, p => p.LastName, p => p.DOB, p => p.RM2Number, p => p.PostCode, p => p.Gender, p => p.PatientStatusId, p => p.DateOfDeath, p => p.GenericNote)) { try { _context.SaveChanges(); } catch (DbUpdateException ex) { var message = ex.Message; ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists, " + "see your system administrator."); } } else { Hashtable errors = ModelStateHelper.Errors(ModelState); return(Json(new { success = false, errors })); } return(Json(new { result = "ok" })); }