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 void SetupTest() { var connection = DbConnectionFactory.CreateTransient(); _context = new PHSContext(connection); _unitOfWork = new MockUnitOfWork(_context); _formManager = new MockFormManager(_unitOfWork); _target = new MockParticipantJourneyManager(_unitOfWork); }
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 CleanupTest() { // dispose of the database and connection _context.Dispose(); _unitOfWork.Dispose(); _target.Dispose(); _unitOfWork = null; _context = null; _formManager = null; _target = null; }
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 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 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 static string GetTempRegistrationFormValue(this HtmlHelper helper, TemplateFieldViewModel model, string fieldType = "", string returnIfNull = "") { if (!string.IsNullOrEmpty(model.RegistrationFieldName)) { using (var participantjourneyManager = new ParticipantJourneyManager()) { var participant = participantjourneyManager.FindParticipant(model.ParticipantNric); if (participant != null) { var value = GetValueFromParticipant(helper, model.RegistrationFieldName, participant); if (value != null) { switch (model.FieldType) { case TemplateFieldType.ADDRESS: AddressViewModel addressViewModel = AddressViewModel.Initialize(participant.Address); if (fieldType == "Blk") { return(addressViewModel.Blk); } else if (fieldType == "Unit") { return(addressViewModel.Unit); } else if (fieldType == "StreetAddress") { return(addressViewModel.StreetAddress); } else if (fieldType == "ZipCode") { return(participant.PostalCode); } break; case TemplateFieldType.BIRTHDAYPICKER: var birthdayValue = participant.DateOfBirth.Value.ToString("dd/M/yyyy"); if (!string.IsNullOrEmpty(birthdayValue)) { string[] values = birthdayValue.Split("/"); if (fieldType == "Day") { int dayValue = int.Parse(values[0]); return((dayValue < 10) ? ("0" + dayValue) : values[0]); } else if (fieldType == "Month") { return(values[1]); } else if (fieldType == "Year") { return(values[2].Substring(0, 4)); } } else { return(""); } break; default: return(value.ToString()); } } } } } return(returnIfNull); }
public ActionResult GenerateLabel() { string templatePath = Server.MapPath("~/App_Data/Label.docx"); // Load template into memory var doc = DocX.Load(templatePath); ParticipantJourneySearchViewModel psm = (ParticipantJourneySearchViewModel)TempData.Peek("ParticipantJourneySearchViewModel"); using (var participantJourneyManager = new ParticipantJourneyManager()) { string message = string.Empty; MessageType messageType = MessageType.ERROR; ParticipantJourneyViewModel result = participantJourneyManager.RetrieveParticipantJourney(psm, out message, out messageType); doc.ReplaceText("<<EVENT>>", result.Event.Title + " " + result.Event.Venue); doc.ReplaceText("<<CURRENT_DATE>>", DateTime.Now.ToString("dd/MM/yyyy HH:mm")); doc.ReplaceText("<<NAME>>", UtilityHelper.GetString(result.FullName).Limit(35)); doc.ReplaceText("<<NRIC>>", UtilityHelper.GetString(result.Nric)); doc.ReplaceText("<<GENDER>>", UtilityHelper.GetString(result.Gender)); doc.ReplaceText("<<DOB>>", UtilityHelper.GetString(result.DateOfBirth)); doc.ReplaceText("<<RACE>>", UtilityHelper.GetString(result.Race).Limit(8)); doc.ReplaceText("<<HOME>>", UtilityHelper.GetString(result.HomeNumber).Limit(8)); doc.ReplaceText("<<HP>>", UtilityHelper.GetString(result.MobileNumber).Limit(8)); doc.ReplaceText("<<ADD>>", UtilityHelper.GetString(result.GetAddressWithoutPrefix()).Limit(48)); //doc.ReplaceText("<<UNIT>>", result.un); doc.ReplaceText("<<POSTAL>>", UtilityHelper.GetString(result.PostalCode)); doc.ReplaceText("<<LANG>>", UtilityHelper.GetString(result.Language).Limit(8)); var ms = new MemoryStream(); doc.SaveAs(ms); ms.Position = 0; byte[] fileBytes = ms.ToArray(); String guid = Guid.NewGuid().ToString(); TempData[guid] = fileBytes; /* * return new JsonResult() * { * Data = new { FileGuid = guid, FileName = psm.Nric + ".docx" } * }; */ Document docTest = new Document(); docTest.LoadFromStream(ms, FileFormat.Docx); MemoryStream stream = new MemoryStream(); docTest.SaveToStream(stream, FileFormat.PDF); stream.Flush(); //Always catches me out stream.Position = 0; //Not sure if this is required TempData[guid] = stream.ToArray(); return(new JsonResult() { Data = new { FileGuid = guid, FileName = psm.Nric + ".pdf" } }); /* * //return File(stream, "application/pdf"); * Response.AppendHeader("Content-Disposition", "inline; filename=name.pdf"); * return new FileContentResult(stream.ToArray(), "application/pdf"); */ } }
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)); } } }