public ParticipantJourneyModality RetrieveParticipantJourneyModality(ParticipantJourneySearchViewModel psm, int formID, int modalityID, out string message) { message = string.Empty; ParticipantJourneyModality 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"; } else { using (var unitOfWork = CreateUnitOfWork()) { result = unitOfWork.ParticipantJourneyModalities.GetParticipantJourneyModality(psm.Nric, psm.PHSEventId, formID, modalityID); } } return(result); }
public void RetrieveParticipantJourney_NoParticipantMessage() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 1; PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-2), EndDT = DateTime.Now.AddDays(1), IsActive = true }; _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); string message = string.Empty; MessageType messageType = MessageType.ERROR; ParticipantJourneyViewModel result = _target.RetrieveParticipantJourney(psm, out message, out messageType); Assert.IsNull(result); Assert.AreEqual("No registration record found. Do you want to register this Nric?", message); }
public void RegisterParticipant_AlreadyHasPHSEvent() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 1; PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(1), IsActive = true }; Participant participant = new Participant() { Nric = "S8250369B", DateOfBirth = DateTime.Now }; _unitOfWork.Events.Add(phsEvent); participant.PHSEvents.Add(phsEvent); _unitOfWork.Participants.Add(participant); _unitOfWork.Complete(); string result = _target.RegisterParticipant(psm); Assert.AreEqual("Invalid register participant", result); }
public void RetrieveParticipantJourney_NotActiveEvent() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 1; PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-2), EndDT = DateTime.Now.AddDays(-1), IsActive = false }; _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); string message = string.Empty; MessageType messageType = MessageType.ERROR; ParticipantJourneyViewModel result = _target.RetrieveParticipantJourney(psm, out message, out messageType); Assert.IsNull(result); Assert.AreEqual("Screening Event is not active", message); }
public ActionResult RefreshViewParticipantJourneyParticipant() { ParticipantJourneySearchViewModel psm = (ParticipantJourneySearchViewModel)TempData.Peek("ParticipantJourneySearchViewModel"); if (psm == null) { return(Redirect("Index")); } using (var participantJourneyManager = new ParticipantJourneyManager()) { 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")); } return(PartialView("_ViewParticipantJourneyParticipantPartial", result)); } }
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)); } }
// GET: ParticipantJourney public ActionResult Index() { using (var participantJourneyManager = new ParticipantJourneyManager()) { ParticipantJourneySearchViewModel result = participantJourneyManager.RetrieveActiveScreeningEvent(); return(View(result)); } }
public ParticipantJourneySearchViewModel RetrieveActiveScreeningEvent() { using (var unitOfWork = CreateUnitOfWork()) { ParticipantJourneySearchViewModel result = new ParticipantJourneySearchViewModel(); //result.PHSEvents = unitOfWork.Events.GetAll(); result.PHSEvents = unitOfWork.Events.GetAllActiveEvents(); return(result); } }
public ActionResult InternalFillIn(IDictionary <string, string> SubmitFields, TemplateViewModel model, FormCollection formCollection) { InsertValuesIntoTempData(formCollection); using (var participantJourneyManager = new ParticipantJourneyManager(GetLoginUser())) { var template = participantJourneyManager.FindTemplate(model.TemplateID.Value); var templateView = TemplateViewModel.CreateFromObject(template, Constants.TemplateFieldMode.INPUT); string nric = null; string eventId = null; int modalityId = -1; if (TempData.Peek("SelectedModalityId") != null) { modalityId = (int)TempData.Peek("SelectedModalityId"); } ParticipantJourneySearchViewModel psm = (ParticipantJourneySearchViewModel)TempData.Peek("ParticipantJourneySearchViewModel"); if (psm != null) { eventId = psm.PHSEventId.ToString(); nric = psm.Nric; } string result = participantJourneyManager.InternalFillIn(psm, modalityId, SubmitFields, model, formCollection); if (result.Equals("success")) { List <ParticipantJourneyModalityCircleViewModel> participantJourneyModalityCircles = (List <ParticipantJourneyModalityCircleViewModel>)TempData.Peek("ParticipantJourneyModalityCircleViewModel"); foreach (var participantJourneyModalityCircle in participantJourneyModalityCircles) { if (participantJourneyModalityCircle.isModalityFormsContain(templateView.FormID)) { participantJourneyModalityCircle.modalityCompletedForms.Add(templateView.FormID); } } RemoveValuesFromTempData(formCollection); TempData["ParticipantJourneyModalityCircleViewModel"] = participantJourneyModalityCircles; //TempData["success"] = templateView.ConfirmationMessage; return(Json(new { success = true, message = "Your changes were saved.", isautosave = false })); } else { //TempData["error"] = result; return(Json(new { success = false, error = result, isautosave = false })); } } }
public void RegisterParticipant_InvalidNric() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S82"; psm.PHSEventId = 1; string result = _target.RegisterParticipant(psm); Assert.AreEqual("Invalid Nric", result); }
public string InternalFillIn(ParticipantJourneySearchViewModel psm, int modalityId, IDictionary <string, string> SubmitFields, TemplateViewModel model, FormCollection formCollection) { using (var unitOfWork = CreateUnitOfWork()) { var template = FindTemplate(model.TemplateID.Value, unitOfWork); using (var fillIn = new InternalFormFillIn(unitOfWork, psm, template.FormID, modalityId, GetLoginUserName())) { return(fillIn.FillIn(SubmitFields, template, formCollection)); } } }
public void RetrieveParticipantJourney_InvalidNric() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S82"; psm.PHSEventId = 1; string message = string.Empty; MessageType messageType = MessageType.ERROR; _target.RetrieveParticipantJourney(psm, out message, out messageType); Assert.AreEqual("Invalid Nric", message); }
public void RetrieveParticipantJourneyModality_NoRecordFound() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 1; int formId = 1; string message = string.Empty; ParticipantJourneyModality result = _target.RetrieveParticipantJourneyModality(psm, formId, 1, out message); Assert.IsNull(result); }
public ActionResult SearchParticipantJourney(ParticipantJourneySearchViewModel psm) { if (psm == null) { return(View()); } using (var participantJourneyManager = new ParticipantJourneyManager()) { string message = string.Empty; MessageType messageType = MessageType.ERROR; ParticipantJourneyViewModel result = participantJourneyManager.RetrieveParticipantJourney(psm, out message, out messageType); if (result == null) { if (MessageType.ERROR == messageType) { SetViewBagError(message); } else { SetViewBagMessage(message); } TempData["ToRegister"] = psm; if (Request.IsAjaxRequest()) { return(PartialView("_SearchParticipantJourneyResultPartial", psm)); } else { return(View(psm)); } } else { string url = Url.Action("ViewParticipantJourney", "ParticipantJourney", new { Nric = psm.Nric, PHSEventId = psm.PHSEventId }); return(JavaScript("window.location = '" + url + "'")); } } }
public TemplateViewModel FindTemplateToDisplay(ParticipantJourneySearchViewModel psm, int formID, int selectedModalityId, bool embed, TemplateFieldMode fieldMode, out string message) { TemplateViewModel model = null; using (var unitOfWork = CreateUnitOfWork()) { ParticipantJourneyModality participantJourneyModality = RetrieveParticipantJourneyModality(psm, formID, selectedModalityId, out message); if (participantJourneyModality != null) { var template = participantJourneyModality.TemplateID.HasValue ? unitOfWork.FormRepository.GetTemplate(participantJourneyModality.TemplateID.Value) : FindLatestTemplate(formID, unitOfWork); if (template != null) { model = TemplateViewModel.CreateFromObject(template, Constants.TemplateFieldMode.INPUT); model.Embed = embed; bool valueRequiredForRegistration = false; if (Internal_Form_Type_Registration.Equals(model.InternalFormType)) { if (participantJourneyModality.EntryId == Guid.Empty) { valueRequiredForRegistration = true; } } foreach (var field in model.Fields) { field.Mode = fieldMode; field.ParticipantNric = psm.Nric; field.IsValueRequiredForRegistration = valueRequiredForRegistration; field.EntryId = participantJourneyModality.EntryId.ToString(); } } } else { throw new Exception("No participantJourneyModality found"); } return(model); } }
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 void RetrieveActiveScreeningEvent_NoActiveEventWhenNonBetweenStartEndDate() { PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-2), EndDT = DateTime.Now.AddDays(-1), IsActive = true }; _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); ParticipantJourneySearchViewModel result = _target.RetrieveActiveScreeningEvent(); Assert.IsNotNull(result); Assert.AreEqual(0, result.PHSEvents.Count()); }
public void RetrieveParticipantJourney_FoundParticipant() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 1; PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-2), EndDT = DateTime.Now.AddDays(1), IsActive = true }; Participant participant = new Participant() { Nric = "S8250369B", DateOfBirth = DateTime.Now }; _unitOfWork.Events.Add(phsEvent); participant.PHSEvents.Add(phsEvent); _unitOfWork.Participants.Add(participant); _unitOfWork.Complete(); string message = string.Empty; MessageType messageType = MessageType.ERROR; ParticipantJourneyViewModel result = _target.RetrieveParticipantJourney(psm, out message, out messageType); Assert.AreEqual(string.Empty, message); Assert.IsNotNull(result); Assert.IsNotNull(result.Event); Assert.AreEqual(phsEvent.PHSEventID, result.Event.PHSEventID); }
public ActionResult ActivateCirclesFromMSSS(string activateList) { ICollection <ParticipantJourneyModalityCircleViewModel> modalityList = (List <ParticipantJourneyModalityCircleViewModel>)TempData.Peek("ParticipantJourneyModalityCircleViewModel"); if (!string.IsNullOrEmpty(activateList)) { string[] activateArray = activateList.Split('|'); for (int i = 0; i < modalityList.Count; i++) { if (activateArray.ElementAt(i) == "1") { modalityList.ElementAt(i).IsActive = true; } else { modalityList.ElementAt(i).IsActive = false; } } } using (var participantJourneyManager = new ParticipantJourneyManager(GetLoginUser())) { String updateResults = "Failed"; updateResults = participantJourneyManager.UpdateParticipantJourneyModalityFromMSS(modalityList); ParticipantJourneySearchViewModel psm = (ParticipantJourneySearchViewModel)TempData.Peek("ParticipantJourneySearchViewModel"); List <ParticipantJourneyModalityCircleViewModel> pjmcyvmItems = participantJourneyManager.GetParticipantMegaSortingStation(psm); if (updateResults.Equals("Failed")) { return(View("_MegaSortingStationPartial.cshtml", pjmcyvmItems)); } else { return(PartialView("_ViewParticipantJourneyCirclePartial", modalityList)); } } }
public void InternalFillIn_ExceptionRequiredParticipantJourneyModality() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 1; TemplateViewModel templateViewModel = CreateFormAndTemplateWithSampleField(); FormCollection submissionCollection = new FormCollection(); submissionCollection.Add("SubmitFields[1].TextBox", "HelloTest"); IDictionary <string, string> submissionFields = new System.Collections.Generic.Dictionary <string, string>(); submissionFields.Add("1", "1"); string result = _target.InternalFillIn(psm, 1, submissionFields, templateViewModel, submissionCollection); Assert.AreEqual(result, "success"); Assert.Fail("Expecting exception"); }
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 ActionResult RegisterParticipant() { ParticipantJourneySearchViewModel psm = (ParticipantJourneySearchViewModel)TempData["ToRegister"]; if (psm == null) { SetViewBagMessage("No Participant information found"); return(RedirectToAction("Index", psm)); } using (var participantJourneyManager = new ParticipantJourneyManager(GetLoginUser())) { string result = participantJourneyManager.RegisterParticipant(psm); if (!result.Equals("success")) { SetViewBagMessage(result); return(RedirectToAction("Index", psm)); } return(RedirectToAction("ViewParticipantJourney", psm)); } }
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 void RegisterParticipant_NotActiveEvent() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 1; PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-2), EndDT = DateTime.Now.AddDays(-1), IsActive = false }; _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); string result = _target.RegisterParticipant(psm); Assert.AreEqual("Screening Event is not active", result); }
public ParticipantJourneyViewModel RetrievePastParticipantJourney(ParticipantJourneySearchViewModel psm, out string message) { message = string.Empty; ParticipantJourneyViewModel 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 an Event"; } else { using (var unitOfWork = CreateUnitOfWork()) { Participant participant = unitOfWork.Participants.FindParticipant(psm.Nric, psm.PHSEventId); if (participant != null) { result = new ParticipantJourneyViewModel(participant, psm.PHSEventId); } else { message = "No result found"; } } } return(result); }
public InternalFormFillIn(IUnitOfWork unitOfWork, ParticipantJourneySearchViewModel psm, int formId, int modalityId, string userName) : base(unitOfWork, userName) { this.psm = psm; this.formId = formId; this.modalityId = modalityId; }
public void RegisterParticipant_ExistingParticipantAndPHSEventWithPreRegistration() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 2; PHSEvent phsEventOne = new PHSEvent() { Title = "Test 15", Venue = "Test", StartDT = DateTime.Now.AddDays(-200), EndDT = DateTime.Now.AddDays(-199), IsActive = false }; PHSEvent phsEventTwo = new PHSEvent() { Title = "Test 16", Venue = "Test", StartDT = DateTime.Now.AddDays(-2), EndDT = DateTime.Now.AddDays(1), IsActive = true }; Participant participant = new Participant() { Nric = "S8250369B", DateOfBirth = DateTime.Now, HomeNumber = "88776655" }; PreRegistration preRegistration = new PreRegistration() { Nric = "S8250369B", Address = "Test Add", Citizenship = "Singaporean", HomeNumber = "12345678", FullName = "Tester", Gender = "Male", Salutation = "Mr", Race = "Chinese", Language = "English", DateOfBirth = DateTime.Now, EntryId = Guid.NewGuid() }; Modality modality = new Modality() { Name = "Test Modality", IsMandatory = true }; Form form = new Form { Title = "Test form" }; _unitOfWork.PreRegistrations.Add(preRegistration); _unitOfWork.Events.Add(phsEventOne); _unitOfWork.Events.Add(phsEventTwo); participant.PHSEvents.Add(phsEventOne); _unitOfWork.Participants.Add(participant); modality.Forms.Add(form); phsEventTwo.Modalities.Add(modality); _unitOfWork.Complete(); string message = string.Empty; MessageType messageType = MessageType.ERROR; ParticipantJourneyViewModel preResult = _target.RetrieveParticipantJourney(psm, out message, out messageType); Assert.IsNull(preResult); string registerResult = _target.RegisterParticipant(psm); Assert.AreEqual("success", registerResult); ParticipantJourneyViewModel postResult = _target.RetrieveParticipantJourney(psm, out message, out messageType); Assert.IsNotNull(postResult); Assert.IsNotNull(postResult.Event); Assert.AreEqual("12345678", postResult.HomeNumber); var pjmResult = _unitOfWork.ParticipantJourneyModalities.Find(u => u.PHSEventID == postResult.Event.PHSEventID).FirstOrDefault(); Assert.IsNotNull(pjmResult); Assert.AreEqual(1, pjmResult.ParticipantID); Assert.AreEqual(1, pjmResult.ModalityID); Assert.AreEqual(2, pjmResult.PHSEventID); Assert.AreEqual(1, pjmResult.FormID); }
public void FindTemplateToDisplay_OlderVersionAfterSubmitBefore() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 1; int formId = 1; PHSEvent phsEvent = new PHSEvent() { Title = "Test 15", Venue = "Test", StartDT = DateTime.Now.AddDays(-200), EndDT = DateTime.Now.AddDays(-199), IsActive = false }; Participant participant = new Participant() { Nric = "S8250369B" }; Modality modality = new Modality() { Name = "Test Modality" }; Form form = new Form { IsActive = true, Title = "Test form" }; Template templateOne = new Template() { Status = Constants.TemplateStatus.DRAFT.ToString(), IsActive = true, Version = 1, DateAdded = DateTime.Now }; Template templateTwo = new Template() { Status = Constants.TemplateStatus.DRAFT.ToString(), IsActive = true, Version = 2, DateAdded = DateTime.Now }; _unitOfWork.Events.Add(phsEvent); participant.PHSEvents.Add(phsEvent); _unitOfWork.Participants.Add(participant); form.Templates.Add(templateOne); form.Templates.Add(templateTwo); modality.Forms.Add(form); phsEvent.Modalities.Add(modality); _unitOfWork.Complete(); ParticipantJourneyModality journeyModality = new ParticipantJourneyModality() { ParticipantID = 1, PHSEventID = psm.PHSEventId, ModalityID = 1, FormID = formId, TemplateID = 1 }; _unitOfWork.ParticipantJourneyModalities.Add(journeyModality); _unitOfWork.Complete(); string message = string.Empty; var result = _target.FindTemplateToDisplay(psm, formId, 1, false, TemplateFieldMode.INPUT, out message); Assert.IsNotNull(result); var templateResult = _target.FindTemplate(result.TemplateID.Value); Assert.IsNotNull(templateResult); Assert.AreEqual(1, templateResult.Version); }
public void RetrieveParticipantJourneyModality_ShouldHaveRecord() { ParticipantJourneySearchViewModel psm = new ParticipantJourneySearchViewModel(); psm.Nric = "S8250369B"; psm.PHSEventId = 1; int formId = 1; Guid entryId = new Guid(); PHSEvent phsEvent = new PHSEvent() { Title = "Test 15", Venue = "Test", StartDT = DateTime.Now.AddDays(-200), EndDT = DateTime.Now.AddDays(-199), IsActive = false }; Participant participant = new Participant() { Nric = "S8250369B", DateOfBirth = DateTime.Now, HomeNumber = "88776655" }; Modality modality = new Modality() { Name = "Test Modality" }; Form form = new Form { Title = "Test form" }; _unitOfWork.Events.Add(phsEvent); participant.PHSEvents.Add(phsEvent); _unitOfWork.Participants.Add(participant); modality.Forms.Add(form); phsEvent.Modalities.Add(modality); ParticipantJourneyModality journeyModality = new ParticipantJourneyModality() { ParticipantID = 1, PHSEventID = psm.PHSEventId, ModalityID = 1, FormID = formId, EntryId = entryId }; _unitOfWork.ParticipantJourneyModalities.Add(journeyModality); _unitOfWork.Complete(); string message = string.Empty; ParticipantJourneyModality result = _target.RetrieveParticipantJourneyModality(psm, formId, 1, out message); Assert.IsNotNull(result); Assert.AreEqual(entryId, result.EntryId); }