public void GetAllFUConfigurationTest_ShouldHaveRecords() { PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(1), IsActive = true }; FollowUpConfiguration followUpConfiguration = new FollowUpConfiguration() { Title = "Test Configuration", PHSEventID = 1, Deploy = false }; phsEvent.FollowUpConfigurations.Add(followUpConfiguration); _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); var result = _target.GetAllFUConfiguration(); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count()); }
public List <ParticipantJourneyModalityCircleViewModel> GetParticipantMegaSortingStation(ParticipantJourneySearchViewModel psm) { using (var unitOfWork = CreateUnitOfWork()) { PHSEvent phsEvent = unitOfWork.Events.Get(psm.PHSEventId); Participant participant = unitOfWork.Participants.FindParticipant(psm.Nric, phsEvent.PHSEventID); IEnumerable <ParticipantJourneyModality> ptJourneyModalityItems = unitOfWork.ParticipantJourneyModalities.GetParticipantJourneyModalityByParticipantEvent(psm.Nric, phsEvent.PHSEventID); ParticipantJourneyViewModel pjvm = new ParticipantJourneyViewModel(participant, psm.PHSEventId); List <ParticipantJourneyModalityCircleViewModel> pjmCircles = new List <ParticipantJourneyModalityCircleViewModel>(); foreach (Modality modality in phsEvent.Modalities) { IList <ParticipantJourneyModality> matchedPjms = new List <ParticipantJourneyModality>(); foreach (ParticipantJourneyModality pjm in ptJourneyModalityItems) { if (modality.ModalityID == pjm.Modality.ModalityID && pjm.PHSEvent.Equals(phsEvent)) { matchedPjms.Add(pjm); modality.IsActive = true; } } if (modality.IsVisible && modality.Status != "Public") { pjmCircles.Add(copyToPJMCVM(pjvm, modality, matchedPjms)); } } return(pjmCircles); } }
public bool NewEvent(PHSEvent eventModel, out string message) { message = string.Empty; validateEvent(eventModel, out message); if (message != string.Empty) { return(false); } using (var unitOfWork = CreateUnitOfWork()) { foreach (var newModality in eventModel.Modalities) { newModality.IsActive = true; } eventModel.CreatedDateTime = DateTime.Now; eventModel.IsActive = true; unitOfWork.Events.Add(eventModel); using (TransactionScope scope = new TransactionScope()) { unitOfWork.Complete(); scope.Complete(); } return(true); } }
public void GetModalityByIDTest_NoRecord() { PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(1), IsActive = true }; Modality modality = new Modality() { Name = "Test Modality", IsMandatory = true, IsActive = false }; phsEvent.Modalities.Add(modality); _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); string message = string.Empty; var result = _target.GetModalityByID(3, out message); Assert.IsNull(result); Assert.AreEqual("Modality Not Found", message); }
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 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); }
private void validateEvent(PHSEvent eventModel, out string message) { if (eventModel == null) { message = Constants.PleaseFillInAllRequiredFields(); return; } if ((string.IsNullOrEmpty(eventModel.Title) || string.IsNullOrEmpty(eventModel.Title.Trim())) || (string.IsNullOrEmpty(eventModel.Venue) || string.IsNullOrEmpty(eventModel.Venue.Trim())) ) { message = Constants.PleaseFillInAllRequiredFields(); return; } if (EventTitleExists(eventModel.Title, out message)) { return; } if (eventModel.StartDT == null || eventModel.EndDT == null) { message = Constants.PleaseFillInAllRequiredFields(); return; } if (eventModel.StartDT <= DateTime.Today || eventModel.EndDT <= DateTime.Today) { message = "Input Date must larger than today"; return; } }
public void DeleteEventTest_Success() { PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(1), IsActive = true }; _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); string message = string.Empty; var record = _target.GetEventByID(1, out message); Assert.IsNotNull(record); var saveResult = _target.DeleteEvent(record.PHSEventID, out message); Assert.IsTrue(saveResult); var result = _target.GetEventByID(record.PHSEventID, out message); Assert.IsNull(result); Assert.AreEqual("Event Not Found", 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 ActionResult Create() { //List<Template> templates; //using (var formManager = new FormManager()) //{ // templates = formManager.FindAllTemplates(); // ViewData["ss"] = templates; // String htmlString = "<select id=\"SelectedForm\" name=\"Modalities[0].FormID\">"; // // String htmlString = ""; // foreach (var template in templates) // { // var templateView = TemplateViewModel.CreateFromObject(template); // htmlString += "<option value=\"" + template.TemplateID + "\">" + templateView.Title + "</option>"; // } // htmlString += "</select>"; // ViewData["Forms"] = htmlString; //} //Create default Modalities PHSEvent phsEvent = buildDefaultEvent(); return(View(phsEvent)); }
public ActionResult EditModalityForm(int eventid, int modalityid) { using (var formManager = new FormManager()) { ModalityFormViewModel model = new ModalityFormViewModel(); model.ModalityFormList = formManager.FindModalityForm(modalityid); model.ModalityID = modalityid; model.EventID = eventid; using (var modalityManager = new ModalityManager(GetLoginUser())) { string message = string.Empty; Modality modality = modalityManager.GetModalityByID(modalityid, out message); model.ModalityName = modality.Name; } using (var eventManager = new EventManager()) { string message = string.Empty; PHSEvent phsEvent = eventManager.GetEventByID(eventid, out message); model.EventName = phsEvent.Title; } return(View(model)); } }
public ActionResult Create([Bind(Exclude = "ID")] PHSEvent eventModel) { string message = string.Empty; using (var eventManager = new EventManager(GetLoginUser())) { //Person loginUser = GetLoginUser(); //if(loginUser != null) //{ // eventModel.CreatedBy = loginUser.PersonID; //} //else //{ eventModel.CreatedBy = ""; //} eventModel.Modalities = BuildDefaultModalites(); bool isCreated = eventManager.NewEvent(eventModel, out message); if (isCreated == false) { SetViewBagError(message); return(View(eventModel)); } } return(RedirectToAction("Index")); }
public void AddToPublicFacing(int formID, int eventID, string publicFormType) { Form form; try { using (var unitOfWork = CreateUnitOfWork()) { form = unitOfWork.FormRepository.Get(formID); PHSEvent phsEvent = unitOfWork.Events.Get(eventID); string publicURL = phsEvent.Title.Replace(" ", "") + "_" + form.Title.Replace(" ", "").Substring(0, 6); form.IsPublic = true; form.PublicFormType = publicFormType; form.Slug = publicURL; using (TransactionScope scope = new TransactionScope()) { unitOfWork.Complete(); scope.Complete(); } } } catch { } }
public void GetFUConfigurationByIDTest_ShouldHaveRecord() { PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(1), IsActive = true }; FollowUpConfiguration followUpConfiguration = new FollowUpConfiguration() { Title = "Test Configuration", PHSEventID = 1, Deploy = false }; phsEvent.FollowUpConfigurations.Add(followUpConfiguration); _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); string message = string.Empty; var result = _target.GetFUConfigurationByID(1, out message); Assert.IsNotNull(result); Assert.AreEqual("Test Configuration", result.Title); Assert.AreEqual(string.Empty, message); }
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); }
private PHSEvent buildDefaultEvent() { List <Modality> modalities = BuildDefaultModalites(); PHSEvent phsEvent = new PHSEvent(); phsEvent.Modalities = modalities; return(phsEvent); }
public ActionResult Edit([Bind(Include = "PHSEventID,Title,Venue,StartDT,EndDT")] PHSEvent eventModel) { using (var eventManager = new EventManager(GetLoginUser())) { eventManager.UpdateEvent(eventModel); } return(RedirectToAction("Index")); }
public void UpdateModalityTest_Success() { PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(1), IsActive = true }; Modality modality = new Modality() { Name = "Test Modality", IsMandatory = true, IsActive = false }; phsEvent.Modalities.Add(modality); _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); string message = string.Empty; var result = _target.GetModalityByID(1, out message); Assert.IsNotNull(result); ModalityEventViewModel modalityEventViewModel = new ModalityEventViewModel() { Name = "Test Modality 1234", IsMandatory = true, IsActive = false, EventID = 1, ModalityID = 1, ModalityRole = new List <ModalityRole>() }; var saveResult = _target.UpdateModality(modalityEventViewModel, out message); Assert.IsTrue(saveResult); Assert.AreEqual(string.Empty, message); result = _target.GetModalityByID(1, out message); Assert.IsNotNull(result); Assert.AreEqual("Test Modality 1234", result.Name); Assert.AreEqual(string.Empty, message); }
public bool NewModality(ModalityEventViewModel modalityEventView, out string message) { message = string.Empty; Modality modality = new Modality(); Util.CopyNonNullProperty(modalityEventView, modality); modality.IsActive = true; modality.IsVisible = true; modality.IsMandatory = false; using (var unitOfWork = CreateUnitOfWork()) { PHSEvent phsEvent = unitOfWork.Events.GetEvent(modalityEventView.EventID); int count = phsEvent.Modalities.Count; modality.Position = count; string roleToUpdate = string.Empty; foreach (var modalityRole in modalityEventView.ModalityRole) { if (modalityRole.Checked) { roleToUpdate += Constants.Form_Option_Split_Concate + modalityRole.Name; } } if (!string.IsNullOrEmpty(roleToUpdate)) { roleToUpdate = roleToUpdate.Remove(0, 1); } modality.Role = roleToUpdate; phsEvent.Modalities.Add(modality); using (TransactionScope scope = new TransactionScope()) { unitOfWork.Complete(); scope.Complete(); } return(true); } }
public void NewEventTest_FailedValidationDueToStartTimeLessThanToday() { PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(10), IsActive = false }; string message = string.Empty; var saveResult = _target.NewEvent(phsEvent, out message); Assert.IsFalse(saveResult); Assert.AreEqual("Input Date must larger than today", message); }
public void GetAllEventsTest_ShouldHaveRecords() { PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(1), IsActive = true }; _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); var result = _target.GetAllEvents(); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count()); }
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 ImportCallerTest_NoRecords() { string message = string.Empty; PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(1), IsActive = true }; FollowUpConfiguration followUpConfiguration = new FollowUpConfiguration() { Title = "Test Configuration", PHSEventID = 1, Deploy = true }; FollowUpGroup followUpGroup = new FollowUpGroup() { Title = "Test Group" }; followUpConfiguration.FollowUpGroups.Add(followUpGroup); phsEvent.FollowUpConfigurations.Add(followUpConfiguration); _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); var projectFolder = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; var file = Path.Combine(projectFolder, @"Files\no data file.xlsx"); byte[] bytes = System.IO.File.ReadAllBytes(file); _target.ImportCaller(bytes, 1, out message); Assert.AreEqual("No Volunteers/Comm Members found.", message); }
public ActionResult Edit(int id) { if (!IsUserAuthenticated()) { return(RedirectToLogin()); } string message = string.Empty; using (var getEvent = new EventManager()) { PHSEvent eventModel = getEvent.GetEventByID(id, out message); if (eventModel == null) { SetViewBagError(message); } SetBackURL("Index"); return(View(eventModel)); }; }
public void DeleteEventModalityTest_Success() { PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(1), IsActive = true }; Modality modality = new Modality() { Name = "Test Modality", IsMandatory = true, IsActive = false }; phsEvent.Modalities.Add(modality); _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); string message = string.Empty; var record = _target.GetEventByID(1, out message); Assert.IsNotNull(record); Assert.AreEqual(1, record.Modalities.Count); var saveResult = _target.DeleteEventModality(1, record.PHSEventID, out message); Assert.IsTrue(saveResult); var result = _target.GetEventByID(record.PHSEventID, out message); Assert.IsNotNull(result); Assert.AreEqual(0, result.Modalities.Count); }
public void DeleteEventTest_UnableToDeleteWithParticipantsRegistered() { 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 message = string.Empty; var record = _target.GetEventByID(1, out message); Assert.IsNotNull(record); var saveResult = _target.DeleteEvent(record.PHSEventID, out message); Assert.IsFalse(saveResult); Assert.AreEqual("Can't delete event with partients!", message); var result = _target.GetEventByID(record.PHSEventID, out message); Assert.IsNotNull(result); }
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 void GetEventByIDTest_NoRecord() { PHSEvent phsEvent = new PHSEvent() { Title = "Test", Venue = "Test", StartDT = DateTime.Now.AddDays(-1), EndDT = DateTime.Now.AddDays(1), IsActive = true }; _unitOfWork.Events.Add(phsEvent); _unitOfWork.Complete(); string message = string.Empty; var result = _target.GetEventByID(3, out message); Assert.IsNull(result); Assert.AreEqual("Event Not Found", message); }
public void RetrieveAllFormsTest() { 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 }; Modality modality = new Modality() { Name = "Test Modality" }; Form form = new Form { Title = "Test form", DateAdded = new DateTime() }; _unitOfWork.Events.Add(phsEvent); modality.Forms.Add(form); phsEvent.Modalities.Add(modality); _unitOfWork.Complete(); string message = string.Empty; var result = _target.RetrieveAllForms(1, out message); Assert.IsNotNull(result); Assert.AreEqual(1, result.Forms.Count); }
public bool UpdateEvent(PHSEvent eventModel) { if (eventModel == null) { return(false); } using (var unitOfWork = CreateUnitOfWork()) { var eventToUpdate = unitOfWork.Events.GetEvent(eventModel.PHSEventID); //foreach (var newModality in eventModel.Modalities) //{ // Modality modality = new Modality(); // modality.Name = newModality.Name; // unitOfWork.Modalities.Add(modality); // eventToUpdate.Modalities.Add(modality); //} eventToUpdate.Title = eventModel.Title; eventToUpdate.Venue = eventModel.Venue; eventToUpdate.StartDT = eventModel.StartDT; eventToUpdate.EndDT = eventModel.EndDT; eventToUpdate.UpdatedDateTime = DateTime.Now; using (TransactionScope scope = new TransactionScope()) { unitOfWork.Complete(); scope.Complete(); } return(true); } }