/// <summary> /// Add a disease to a patient /// </summary> /// <returns></returns> public JsonResult AddDiseaseToPatient() { try { var patientId = int.Parse(Request.Form["patientId"]); var problemId = int.Parse(Request.Form["problemId"]); PatientRepository repo = new PatientRepository(); var patient = repo.Get(patientId); PatientProblemRepository patientProbRepo = new PatientProblemRepository(); ProblemRepository pRepo = new ProblemRepository(); PatientProblem pProblem = new PatientProblem(); pProblem.Problem = pRepo.Get(problemId); pProblem.Patient = patient; patientProbRepo.Add(pProblem); return Json(new { error = "false", Name = pProblem.Problem.ProblemName }); } catch (Exception) { return Json(new { error = "true" }); } }
/// <summary> /// Add new disease /// </summary> /// <returns></returns> public JsonResult CreateNewDisease() { try { ProblemRepository problemRepo = new ProblemRepository(); var problemName = Request.Form["DiseaseName"]; Problem problem = new Problem(); problem.ProblemName = problemName; problemRepo.Add(problem); return Json(new { error = "false", Name = problem.ProblemName }); } catch (Exception) { return Json(new { error = "true" }); } }