public JsonResult EditImmunization() { try { ImmunizationRepository immunizationRepo = new ImmunizationRepository(); Immunization immunization = immunizationRepo.Get(int.Parse(Request.Form["Immunization"])); immunization.VaccineType = Request.Form["EditImmunization"]; return Json(new { error = "false" }); } catch { return Json(new { error = "true" }); } }
/// <summary> /// Add new immunization to patient /// </summary> /// <returns></returns> public JsonResult AddImmunizationToPatient() { try { int patientId = int.Parse(Request.Form["patientID"]); int immunizationId = int.Parse(Request.Form["vaccineType"]); DateTime dateAdministered = DateTime.Parse(Request.Form["dateAdministered"]); PatientRepository repo = new PatientRepository(); var patient = repo.Get(patientId); PatientImmunizationRepository patientImmunRepo = new PatientImmunizationRepository(); ImmunizationRepository immunRepo = new ImmunizationRepository(); PatientImmunization pImmunization = new PatientImmunization(); pImmunization.Immunization = immunRepo.Get(immunizationId); pImmunization.Patient = patient; pImmunization.DateAdministered = dateAdministered; patientImmunRepo.Add(pImmunization); //UnitOfWork.CurrentSession.Flush(); return Json(new { error = "false", status = "Added immunization: " + pImmunization.Immunization.VaccineType + " to patient successfully", immunization = pImmunization.Immunization.VaccineType, dateAdmin = pImmunization.DateAdministered.ToString("dd/MM/yyyy"), id = pImmunization.Id }); } catch (Exception e) { return Json(new { error = "true", status = "Unable to add immunization successfully", errorMessage = e.Message }); } }
public JsonResult DeleteImmunization() { try { ImmunizationRepository immunizationRepo = new ImmunizationRepository(); immunizationRepo.Remove(immunizationRepo.Get(int.Parse(Request.Form["Immunization"]))); return Json(new { error = "false" }); } catch { return Json(new { error = "true" }); } }