public IHttpActionResult PostPatientDiagnosisHistoryDetail(PatientDiagnosisHistoryDetail patientDiagnosisHistoryDetail) { response.status = "FAILURE"; if (!ModelState.IsValid) { response.message = "Bad request."; return Ok(response); } try { db.PatientDiagnosisHistoryDetails.Add(patientDiagnosisHistoryDetail); db.SaveChanges(); response.status = "SUCCESS"; response.objParam1 = patientDiagnosisHistoryDetail; } catch (Exception e) { response.message = e.InnerException.InnerException.Message.ToString(); } return Ok(response); }
public IHttpActionResult PutPatientDiagnosisHistoryDetail(int id, PatientDiagnosisHistoryDetail patientDiagnosisHistoryDetail) { response.status = "FAILURE"; if (!ModelState.IsValid || id != patientDiagnosisHistoryDetail.Id) { response.message = "FAILURE"; return Ok(response); } db.Entry(patientDiagnosisHistoryDetail).State = EntityState.Modified; try { db.SaveChanges(); response.status = "SUCCESS"; response.objParam1 = patientDiagnosisHistoryDetail; } catch (Exception e) { if (!PatientDiagnosisHistoryDetailExists(id)) { response.message = "Diagnosis detail doesn't exist."; } else { response.message = e.InnerException.InnerException.Message.ToString(); } } return Ok(response); }