public async Task <IActionResult> PutPreRegistration(int id, PreRegistration preRegistration) { if (id != preRegistration.Id) { return(BadRequest()); } _context.Entry(preRegistration).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PreRegistrationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <PreRegistration> > PostPreRegistration(PreRegistration preRegistration) { _context.PreRegistrations.Add(preRegistration); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPreRegistration", new { id = preRegistration.Id }, preRegistration)); }
public async Task <ActionResult> Create(PreRegistration preRegistration, IFormFile image) { try { string path; if (image == null && preRegistration.Gender == "Kız") { path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\", "kizogrenci.jpg"); preRegistration.ImagePath = "kizogrenci.jpg"; } else if (image == null && preRegistration.Gender == "Erkek") { path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\", "erkekogrenci.png"); preRegistration.ImagePath = "erkekogrenci.png"; } else { path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\", image.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await image.CopyToAsync(stream); } preRegistration.ImagePath = image.FileName; } preRegistrationService.Add(preRegistration); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { return(View(ex.Message)); } }
private void copyPreRegistrationToParticipant(Participant participant, PreRegistration preRegistration) { if (preRegistration != null) { Util.CopyNonNullProperty(preRegistration, participant); } }
public void Remove(Guid id) { PreRegistration preRegistration = GetById(id); preRegistration.Status = DAL.Entity.Enum.Status.Deleted; Update(preRegistration); }
static void Main(string[] args) { PreRegistration prereg; using (var uow = UoWFactory.Create()) { var rep = uow.Create(); prereg = new PreRegistration(); prereg.Text = "First pre registration"; prereg.Text1 = "Additional text"; var k = rep.Create <PreRegistration>(prereg); uow.Commit(); } var meeting = new Meeting(); meeting.Location = "Location 1"; prereg.Text = "Update preregistratioon text"; prereg.Meeting = meeting; meeting.PreRegistrations.Add(prereg); var prereg1 = new PreRegistration(); prereg1.Text = "New pre registratoob"; prereg1.Meeting = meeting; meeting.PreRegistrations.Add(prereg1); using (var uow = UoWFactory.Create()) { var repository = uow.Create(); var updatedMeeting = repository.UpdateGraph(meeting); uow.Commit(); } //meeting.PreRegistrations.AddRange(new List<PreRegistration>() { prereg, prereg1 }); //using (var uow = UoWFactory.Create()) //{ // context.ChangeTracker.AttachGraph(meeting); // prereg1.Text1 = "lkjalkjslkjslkjslkjlsj"; // meeting.PreRegistrations.Remove(prereg1); // context.SaveChanges(); //} //using (var context = new EF7BloggContext()) //{ // context.Remove(prereg1); // context.SaveChanges(); //} }
public void UpdateUserStatus(int id) { using (EHMSEntities ent = new EHMSEntities()) { PreRegistration pre = (from a in ent.PreRegistrations where a.PreRegistrationID == id select a).First(); pre.Status = false; ent.SaveChanges(); } }
public ActionResult Delete(PreRegistration preRegistration) { try { preRegistrationService.Remove(preRegistration.ID); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
static void Main(string[] args) { PreRegistration prereg; using (var uow = UoWFactory.Create()) { var rep = uow.Create(); prereg = new PreRegistration(); prereg.Text = "First pre registration"; prereg.Text1 = "Additional text"; var k = rep.Create<PreRegistration>(prereg); uow.Commit(); } var meeting = new Meeting(); meeting.Location = "Location 1"; prereg.Text = "Update preregistratioon text"; prereg.Meeting = meeting; meeting.PreRegistrations.Add(prereg); var prereg1 = new PreRegistration(); prereg1.Text = "New pre registratoob"; prereg1.Meeting = meeting; meeting.PreRegistrations.Add(prereg1); using (var uow = UoWFactory.Create()) { var repository = uow.Create(); var updatedMeeting = repository.UpdateGraph(meeting); uow.Commit(); } //meeting.PreRegistrations.AddRange(new List<PreRegistration>() { prereg, prereg1 }); //using (var uow = UoWFactory.Create()) //{ // context.ChangeTracker.AttachGraph(meeting); // prereg1.Text1 = "lkjalkjslkjslkjslkjlsj"; // meeting.PreRegistrations.Remove(prereg1); // context.SaveChanges(); //} //using (var context = new EF7BloggContext()) //{ // context.Remove(prereg1); // context.SaveChanges(); //} }
protected override void HandleAdditionalInsert(TemplateViewModel templateView, Template template, FormCollection formCollection, Guid entryId, IDictionary <int, string> submissionFields) { IDictionary <string, object> values = new Dictionary <string, object>(); foreach (var field in templateView.Fields) { var value = field.SubmittedValue(formCollection); if (!string.IsNullOrEmpty(field.PreRegistrationFieldName)) { values.Add(field.PreRegistrationFieldName, value); } } if (Public_Form_Type_PreRegistration.Equals(template.Form.PublicFormType)) { PreRegistration preRegistration = new PreRegistration(); preRegistration.EntryId = entryId; preRegistration.CreatedDateTime = DateTime.Now; preRegistration.Citizenship = getStringValue(values, PreRegistration_Field_Name_Citizenship); preRegistration.HomeNumber = getStringValue(values, PreRegistration_Field_Name_HomeNumber); preRegistration.MobileNumber = getStringValue(values, PreRegistration_Field_Name_MobileNumber); preRegistration.DateOfBirth = getDateTimeValue(values, PreRegistration_Field_Name_DateOfBirth); preRegistration.Nric = getStringValue(values, PreRegistration_Field_Name_Nric); preRegistration.PreferedTime = getStringValue(values, PreRegistration_Field_Name_PreferedTime); preRegistration.Race = getStringValue(values, PreRegistration_Field_Name_Race); preRegistration.Salutation = getStringValue(values, PreRegistration_Field_Name_Salutation); preRegistration.Language = getStringValue(values, PreRegistration_Field_Name_Language); preRegistration.FullName = getStringValue(values, PreRegistration_Field_Name_FullName); preRegistration.Gender = getStringValue(values, PreRegistration_Field_Name_Gender); string addressValue = getStringValue(values, PreRegistration_Field_Name_Address); if (!string.IsNullOrEmpty(addressValue)) { AddressViewModel address = addressValue.FromJson <AddressViewModel>(); preRegistration.Address = address.ConvertToOneLineAddress(); preRegistration.PostalCode = address.ZipCode; } else { preRegistration.Address = ""; preRegistration.PostalCode = ""; } UnitOfWork.PreRegistrations.Add(preRegistration); } }
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 ParticipantJourneyViewModel RetrieveParticipantJourney(ParticipantJourneySearchViewModel psm, out string message, out MessageType messageType) { message = string.Empty; messageType = MessageType.ERROR; 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 Live Event"; } else if (!NricChecker.IsNRICValid(psm.Nric)) { message = "Invalid Nric"; } else { using (var unitOfWork = CreateUnitOfWork()) { PHSEvent phsEvent = unitOfWork.Events.GetAllActiveEvents().Where(e => e.PHSEventID == psm.PHSEventId).FirstOrDefault(); if (phsEvent == null) { message = "Screening Event is not active"; } else { Participant participant = unitOfWork.Participants.FindParticipant(psm.Nric, psm.PHSEventId); if (participant != null) { result = new ParticipantJourneyViewModel(participant, psm.PHSEventId); } else { messageType = MessageType.PROMPT; PreRegistration preRegistration = unitOfWork.PreRegistrations.FindPreRegistration(p => p.Nric.Equals(psm.Nric)); if (preRegistration == null) { message = "No registration record found. Do you want to register this Nric?"; } else { message = "Do you want to register this Nric?"; } } } } } return(result); }
public string RegisterParticipant(ParticipantJourneySearchViewModel psm) { string result = null; if (psm == null) { return("Parameter cannot be null"); } else if (string.IsNullOrEmpty(psm.Nric) || psm.PHSEventId == 0) { return("Please enter valid NRIC and select Live Event"); } else if (!NricChecker.IsNRICValid(psm.Nric)) { return("Invalid Nric"); } else { using (var unitOfWork = CreateUnitOfWork()) { PHSEvent phsEvent = unitOfWork.Events.GetEventWithModalityForm(psm.PHSEventId); if (phsEvent == null) { return("Screening Event is not active"); } else { Participant participant = unitOfWork.Participants.FindParticipant(psm.Nric); if (participant != null) { if (participant.PHSEvents.All(e => e.PHSEventID == psm.PHSEventId)) { return("Invalid register participant"); } } PreRegistration preRegistration = unitOfWork.PreRegistrations.FindPreRegistration(p => p.Nric.Equals(psm.Nric)); using (TransactionScope scope = new TransactionScope()) { if (participant == null) { participant = new Participant() { Nric = psm.Nric }; copyPreRegistrationToParticipant(participant, preRegistration); unitOfWork.Participants.AddParticipantWithPHSEvent(participant, phsEvent); } else { copyPreRegistrationToParticipant(participant, preRegistration); unitOfWork.Participants.AddPHSEventToParticipant(participant, phsEvent); } foreach (var modality in phsEvent.Modalities) { if (modality.IsMandatory) { foreach (var form in modality.Forms) { ParticipantJourneyModality participantJourneyModality = new ParticipantJourneyModality() { ParticipantID = participant.ParticipantID, PHSEventID = phsEvent.PHSEventID, FormID = form.FormID, ModalityID = modality.ModalityID }; if (!Constants.IsFormForSubmit(form.FormID)) { participantJourneyModality.TemplateID = form.Templates.FirstOrDefault().TemplateID; participantJourneyModality.EntryId = new Guid("10000000-9999-9999-9999-000000000001"); } participant.ParticipantJourneyModalities.Add(participantJourneyModality); } } } unitOfWork.Complete(); scope.Complete(); result = "success"; } } } } return(result); }
public void Update(PreRegistration preRegistration) { context.Entry(preRegistration).State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); }
public void Add(PreRegistration preRegistration) { context.PreRegistrations.Add(preRegistration); context.SaveChanges(); }