public ActionResult RefreshViewParticipantJourneyForm(int selectedModalityId) { ParticipantJourneySearchViewModel psm = (ParticipantJourneySearchViewModel)TempData.Peek("ParticipantJourneySearchViewModel"); if (psm == null) { return(Redirect("Index")); } using (var participantJourneyManager = new ParticipantJourneyManager()) { string message = string.Empty; ParticipantJourneyFormViewModel result = participantJourneyManager.RetrieveParticipantJourneyForm(psm, out message); if (result == null) { SetViewBagError(message); return(Redirect("Index")); } else { TempData["SelectedModalityId"] = selectedModalityId; result.SelectedModalityId = selectedModalityId; } return(PartialView("_ViewParticipantJourneyFormPartial", result)); } }
public void GetModalityFormsForTabsTest() { PHSEvent phsEvent = new PHSEvent() { PHSEventID = 1, Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-200), EndDT = DateTime.Now.AddDays(-198), IsActive = false }; Modality modality = new Modality() { Name = "Test Modality", IsMandatory = true }; Form formOne = new Form { Title = "1. Test form" }; modality.Forms.Add(formOne); Form formTwo = new Form { Title = "3. Test form" }; modality.Forms.Add(formTwo); Form formThree = new Form { Title = "2. Test form" }; modality.Forms.Add(formThree); phsEvent.Modalities.Add(modality); Participant participant = new Participant() { Nric = "S8250369B", DateOfBirth = DateTime.Now }; participant.PHSEvents.Add(phsEvent); ParticipantJourneyFormViewModel _target = new ParticipantJourneyFormViewModel(participant, 1); var result = _target.GetModalityFormsForTabs(); Assert.IsNotNull(result); Assert.AreEqual(3, result.Count); Assert.AreEqual("1. Test form", result[0].Title); Assert.AreEqual("2. Test form", result[1].Title); Assert.AreEqual("3. Test form", result[2].Title); }
public ParticipantJourneyFormViewModel RetrieveParticipantJourneyForm(ParticipantJourneySearchViewModel psm, out string message) { message = string.Empty; ParticipantJourneyFormViewModel result = null; if (psm == null) { message = "Parameter cannot be null"; } else if (string.IsNullOrEmpty(psm.Nric) || psm.PHSEventId == 0) { message = "Please enter valid NRIC and select Live Event"; } //todo: removed for data migration. to put back before live //else if (!NricChecker.IsNRICValid(psm.Nric)) //{ // message = "Invalid Nric"; //} else { using (var unitOfWork = CreateUnitOfWork()) { Participant participant = unitOfWork.Participants.FindParticipant(psm.Nric, psm.PHSEventId); if (participant != null) { result = new ParticipantJourneyFormViewModel(participant, psm.PHSEventId); } else { message = "No result found"; } } } return(result); }
public ActionResult ViewPastParticipantJourney(string Nric, int PHSEventId) { if (string.IsNullOrEmpty(Nric) || PHSEventId == 0) { return(Redirect("Index")); } ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel() { Nric = Nric, PHSEventId = PHSEventId }; using (var participantJourneyManager = new PastParticipantJourneyManager(GetLoginUser())) { string message = string.Empty; ParticipantJourneyViewModel result = participantJourneyManager.RetrievePastParticipantJourney(psm, out message); if (!string.IsNullOrEmpty(message)) { SetViewBagError(message); return(Redirect("Index")); } else { List <ParticipantJourneyModalityCircleViewModel> participantJourneyModalityCircles = participantJourneyManager.GetParticipantMegaSortingStation(psm); ParticipantJourneyFormViewModel participantJourneyformView = new ParticipantJourneyFormViewModel(result.Participant, psm.PHSEventId); participantJourneyformView.SelectedModalityId = result.Event.Modalities.First().ModalityID; TempData["ParticipantJourneySearchViewModel"] = psm; TempData["ParticipantJourneyModalityCircleViewModel"] = participantJourneyModalityCircles; TempData["ParticipantJourneyFormViewModel"] = participantJourneyformView; TempData["SelectedModalityId"] = participantJourneyformView.SelectedModalityId; TempData["ViewParticipantJourneyType"] = Constants.TemplateFieldMode.READONLY; return(View("~/Views/ParticipantJourney/ViewParticipantJourney.cshtml", result)); } } }
public ActionResult ViewParticipantJourney(ParticipantJourneySearchViewModel psm) { if (psm == null) { return(Redirect("Index")); } using (var participantJourneyManager = new ParticipantJourneyManager(GetLoginUser())) { string message = string.Empty; MessageType messageType = MessageType.ERROR; ParticipantJourneyViewModel result = participantJourneyManager.RetrieveParticipantJourney(psm, out message, out messageType); if (result == null) { SetViewBagError(message); return(Redirect("Index")); } else { List <ParticipantJourneyModalityCircleViewModel> participantJourneyModalityCircles = participantJourneyManager.GetParticipantMegaSortingStation(psm); ParticipantJourneyFormViewModel participantJourneyformView = new ParticipantJourneyFormViewModel(result.Participant, psm.PHSEventId); participantJourneyformView.SelectedModalityId = result.Event.Modalities.First().ModalityID; TempData["ParticipantJourneySearchViewModel"] = psm; TempData["ParticipantJourneyModalityCircleViewModel"] = participantJourneyModalityCircles; TempData["ParticipantJourneyFormViewModel"] = participantJourneyformView; TempData["SelectedModalityId"] = participantJourneyformView.SelectedModalityId; TempData["ViewParticipantJourneyType"] = Constants.TemplateFieldMode.INPUT; return(View(result)); } } }
public void RetrieveParticipantJourneyForm_ShouldHaveRecord() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 1; PHSEvent phsEventOne = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-200), EndDT = DateTime.Now.AddDays(-198), IsActive = false }; Participant participant = new Participant() { Nric = "S8250369B", DateOfBirth = DateTime.Now }; _unitOfWork.Events.Add(phsEventOne); participant.PHSEvents.Add(phsEventOne); _unitOfWork.Participants.Add(participant); _unitOfWork.Complete(); string message = string.Empty; ParticipantJourneyFormViewModel result = _target.RetrieveParticipantJourneyForm(psm, out message); Assert.AreEqual(string.Empty, message); Assert.IsNotNull(result); }
public ActionResult InternalFillIn(int id, bool embed = false) { using (var participantJourneyManager = new ParticipantJourneyManager(GetLoginUser())) { ParticipantJourneySearchViewModel psm = (ParticipantJourneySearchViewModel)TempData.Peek("ParticipantJourneySearchViewModel"); if (psm == null) { return(Redirect("Index")); } string message = string.Empty; int selectedModalityId = (int)TempData.Peek("SelectedModalityId"); TemplateFieldMode fieldMode = (TemplateFieldMode)TempData.Peek("ViewParticipantJourneyType"); var result = participantJourneyManager.FindTemplateToDisplay(psm, id, selectedModalityId, embed, fieldMode, out message); if (result == null) { SetViewBagError(message); return(RedirectToError("invalid id")); } else { if (Internal_Form_Type_MegaSortingStation.Equals(result.InternalFormType)) { List <ParticipantJourneyModalityCircleViewModel> pjmcyvmItems = participantJourneyManager.GetParticipantMegaSortingStation(psm); return(PartialView("~/Views/ParticipantJourney/_MegaSortingStationPartial.cshtml", pjmcyvmItems)); } if (Internal_Form_Type_DoctorySummary.Equals(result.InternalFormType)) { ParticipantJourneyFormViewModel pjfvm = participantJourneyManager.RetrieveParticipantJourneyForm(psm, out message); return(PartialView("~/Views/ParticipantJourney/_DoctorSummaryPartial.cshtml", pjfvm)); } //if (Internal_Form_Type_PTSummary.Equals(result.InternalFormType)) //{ // ParticipantJourneyFormViewModel pjfvm = participantJourneyManager.RetrieveParticipantJourneyForm(psm, out message); // return PartialView("~/Views/ParticipantJourney/_PTSummaryPartial.cshtml", pjfvm); //} if (Internal_Form_Type_Cog2Summary.Equals(result.InternalFormType)) { ParticipantJourneyFormViewModel pjfvm = participantJourneyManager.RetrieveParticipantJourneyForm(psm, out message); return(PartialView("~/Views/ParticipantJourney/_Cog2SummaryPartial.cshtml", pjfvm)); } if (Internal_Form_Type_PTSummary.Equals(result.InternalFormType)) { ParticipantJourneyFormViewModel pjfvm = participantJourneyManager.RetrieveParticipantJourneyForm(psm, out message); return(PartialView("~/Views/ParticipantJourney/_PTConsultSummaryPartial.cshtml", pjfvm)); } if (Internal_Form_Type_OTSummary.Equals(result.InternalFormType)) { ParticipantJourneyFormViewModel pjfvm = participantJourneyManager.RetrieveParticipantJourneyForm(psm, out message); return(PartialView("~/Views/ParticipantJourney/_OTConsultSummaryPartial.cshtml", pjfvm)); } if (Internal_Form_Type_Exhibition.Equals(result.InternalFormType)) { ParticipantJourneyFormViewModel pjfvm = participantJourneyManager.RetrieveParticipantJourneyForm(psm, out message); return(PartialView("~/Views/ParticipantJourney/_ExhibitionSummaryPartial.cshtml", pjfvm)); } if (Internal_Form_Type_SocialSupSummary.Equals(result.InternalFormType)) { ParticipantJourneyFormViewModel pjfvm = participantJourneyManager.RetrieveParticipantJourneyForm(psm, out message); return(PartialView("~/Views/ParticipantJourney/_SocialSuportSummaryPartial.cshtml", pjfvm)); } if (Internal_Form_Type_TeleHealthSummary.Equals(result.InternalFormType)) { ParticipantJourneyFormViewModel pjfvm = participantJourneyManager.RetrieveParticipantJourneyForm(psm, out message); return(PartialView("~/Views/ParticipantJourney/_TeleHealthSummaryPartial.cshtml", pjfvm)); } return(View("_FillInPartial", result)); } } }