private async void Delete_Click(object sender, RoutedEventArgs e) { try { int id = int.Parse(txtid.Text); viewModel = new PersonalDetailViewModel(); if (viewModel.DeletePersonal(id)) { MessageDialog md = new MessageDialog("Info has been deleted", "UPDATE OUTCOME"); await md.ShowAsync(); Frame.Navigate(typeof(Views.PersonalPage)); } else { MessageDialog md = new MessageDialog("Info changes NOT updated", "UPDATE OUTCOME"); await md.ShowAsync(); } } catch (Exception ex) { { MessageDialog md = new MessageDialog("Info changes NOT updated", " PLEASE INPUT AN ID"); await md.ShowAsync(); } } }
// Create Personal Details public static async Task <PersonalDetail> CreatePersonalDetails(PersonalDetailViewModel model) { try { using (var db = new WebApiProjectDbContext()) using (var repo = new EntityFrameworkRepository <WebApiProjectDbContext>(db)) { var entity = new PersonalDetail() { Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, BirthDate = model.BirthDate, PhoneNumber = model.PhoneNumber, Age = model.Age, }; repo.Create <PersonalDetail>(entity); var result = await db.SaveChangesAsync() == 0 ? null : entity; return(result); } } catch (Exception e) { Trace.WriteLine(e); return(null); } }
public void FromOutcomeViewModelToCaseDetailsConverter_Set_Variables_test() { var outcome = new PersonalDetailViewModel() { Journey = new Journey { Steps = new List <JourneyStep> { new JourneyStep { QuestionId = "Tx12345", Answer = new Answer { Order = 0 }, State = "{\"PATIENT_AGE\":\"42\",\"PATIENT_GENDER\":\"\\\"M\\\"\",\"PATIENT_PARTY\":\"1\",\"PATIENT_AGEGROUP\":\"Adult\",\"SYSTEM_MERS\":\"mers\",\"SYSTEM_ONLINE\":\"online\"}" }, } } }; var result = Mapper.Map <OutcomeViewModel, CaseDetails>(outcome); Assert.AreEqual(6, result.SetVariables.Count); Assert.IsTrue(result.SetVariables.ContainsKey("PATIENT_AGEGROUP")); Assert.AreEqual("Adult", result.SetVariables["PATIENT_AGEGROUP"]); }
public void FromOutcomeViewModelToCaseDetailsConverter_Condition_test() { var outcome = new PersonalDetailViewModel() { PathwayTitle = "Skin Problems", PathwayId = "PW123MaleChild", PathwayTraumaType = "Trauma", Journey = new Journey { Steps = new List <JourneyStep> { new JourneyStep { QuestionId = "Tx12345", Answer = new Answer { Order = 0 } }, } } }; var result = Mapper.Map <OutcomeViewModel, CaseDetails>(outcome); Assert.AreEqual("Skin Problems", result.StartingPathwayTitle); Assert.AreEqual("PW123MaleChild", result.StartingPathwayId); Assert.AreEqual("Trauma", result.StartingPathwayType); }
public async Task <ActionResult> Confirmation(PersonalDetailViewModel model, [FromUri] bool?overrideFilterServices) { if (!ModelState.IsValid) { //populate address picker fields model = await PopulateAddressPickerFields(model); return(View("PersonalDetails", model)); } var availableServices = await GetServiceAvailability(model, DateTime.Now, overrideFilterServices.HasValue?overrideFilterServices.Value : model.FilterServices, null); _auditLogger.LogDosResponse(model); if (SelectedServiceExits(model.SelectedService.Id, availableServices)) { var outcomeViewModel = ConvertPatientInformantDateToUserinfo(model.PatientInformantDetails, model); outcomeViewModel = await _outcomeViewModelBuilder.ItkResponseBuilder(outcomeViewModel); if (outcomeViewModel.ItkSendSuccess.HasValue && outcomeViewModel.ItkSendSuccess.Value) { return(View(outcomeViewModel)); } return(outcomeViewModel.ItkDuplicate.HasValue && outcomeViewModel.ItkDuplicate.Value ? View("DuplicateBookingFailure", outcomeViewModel) : View("ServiceBookingFailure", outcomeViewModel)); } model.UnavailableSelectedService = model.SelectedService; model.DosCheckCapacitySummaryResult = availableServices; model.DosCheckCapacitySummaryResult.ServicesUnavailable = availableServices.ResultListEmpty; model.UserInfo.CurrentAddress.IsInPilotArea = _postCodeAllowedValidator.IsAllowedPostcode(model.CurrentPostcode) == PostcodeValidatorResponse.InPathwaysArea; return(View("ServiceBookingUnavailable", model)); }
public async Task <ActionResult> EnterHomePostcode(PersonalDetailViewModel model, string changeHomeAddressPostcode) { if (changeHomeAddressPostcode == "unknownHomeAddress") { model.AddressInformation.PatientHomeAddress = null; model.AddressInformation.HomeAddressSameAsCurrentWrapper.HomeAddressSameAsCurrent = HomeAddressSameAsCurrent.DontKnow; return(View("~\\Views\\PersonalDetails\\ConfirmDetails.cshtml", model)); } if (!ModelState.IsValid) { return(View("~\\Views\\PersonalDetails\\HomeAddress_Postcode.cshtml", model)); } else { var postcodes = await GetPostcodeResults(model.AddressInformation.ChangePostcode.Postcode.Replace(" ", "")).ConfigureAwait(false); if (postcodes.ValidatedPostcodeResponse == PostcodeValidatorResponse.PostcodeNotFound) { ModelState.AddModelError("AddressInformation.ChangePostcode.Postcode", new Exception()); return(View("~\\Views\\PersonalDetails\\HomeAddress_Postcode.cshtml", model)); } else if (postcodes.ValidatedPostcodeResponse == PostcodeValidatorResponse.InvalidSyntax) { ModelState.AddModelError("invalid-postcode", "Please enter a valid postcode"); return(View("~\\Views\\PersonalDetails\\HomeAddress_Postcode.cshtml", model)); } model.AddressInformation.PatientHomeAddress.Postcode = model.AddressInformation.ChangePostcode.Postcode; return(View("~\\Views\\PersonalDetails\\ConfirmDetails.cshtml", model)); } }
// Update Personal Details public static async Task <bool> UpdatePersonalDetails(PersonalDetailViewModel model) { try { Errors.Clear(); using (var db = new WebApiProjectDbContext()) using (var repo = new EntityFrameworkRepository <WebApiProjectDbContext>(db)) { var entity = await db.PersonalDetails.FindAsync(model.Id); entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Age = model.Age; entity.BirthDate = model.BirthDate; entity.Email = model.Email; entity.PhoneNumber = model.PhoneNumber; repo.Update <PersonalDetail>(entity); return(await db.SaveChangesAsync() == 0 ? false : true); } } catch (Exception e) { Trace.WriteLine(e); //Add Error message Errors.Add("There was an error trying to send the information to the database"); return(false); } }
public async Task <PersonalDetailViewModel> ConfirmationSurveyLinkBuilder(PersonalDetailViewModel model) { model.SurveyLink = await _surveyLinkViewModelBuilder.SurveyLinkBuilder(model).ConfigureAwait(false); _surveyLinkViewModelBuilder.AddDispositionReason(model.SurveyLink.DispositionChoiceReasoning, model.SurveyLink); return(model); }
private async Task <PersonalDetailViewModel> PopulateAddressPickerFields(PersonalDetailViewModel model) { model.AddressInformation.PatientCurrentAddress.PreviouslyEnteredPostcode = model.CurrentPostcode; var postcodeToUseForSearch = model.CurrentPostcode; if (model.AddressInformation.ChangePostcode != null && !string.IsNullOrEmpty(model.AddressInformation.ChangePostcode.Postcode)) { postcodeToUseForSearch = model.AddressInformation.ChangePostcode.Postcode; } //pre-populate picker fields from postcode lookup service var postcodes = await GetPostcodeResults(postcodeToUseForSearch).ConfigureAwait(false); if (postcodes.ValidatedPostcodeResponse == PostcodeValidatorResponse.PostcodeNotFound) { return(model); } var items = new List <SelectListItem>(); items.AddRange(postcodes.Addresses.Select(postcode => new SelectListItem { Text = postcode.FormattedAddress, Value = postcode.UDPRN }).ToList()); model.AddressInformation.PatientCurrentAddress.AddressPicker = items; return(model); }
public async Task <ActionResult> PersonalDetails(PersonalDetailViewModel model) { ModelState.Clear(); _auditLogger.LogSelectedService(model); return(View("~\\Views\\PersonalDetails\\InformantType.cshtml", new InformantTypeViewModel(model))); }
public async Task <ActionResult> CollectEmailAddress(PersonalDetailViewModel model) { if (ModelState.IsValid) { return(await DirectToPopulatedCurrentAddressPicker(model).ConfigureAwait(false)); } return(View("~\\Views\\PersonalDetails\\CollectEmailAddress.cshtml", model)); }
public async Task <ActionResult> PersonalDetails(PersonalDetailViewModel model) { ModelState.Clear(); await _auditLogger.LogSelectedService(model); model = await PopulateAddressPickerFields(model); return(View("~\\Views\\Outcome\\PersonalDetails.cshtml", model)); }
private async Task <ActionResult> SubmitITKDataToService(PersonalDetailViewModel model) { var outcomeViewModel = ConvertPatientInformantDateToUserinfo(model.EmailAddress, model); var itkConfirmationViewModel = await _outcomeViewModelBuilder.ItkResponseBuilder(outcomeViewModel); var result = _referralResultBuilder.Build(itkConfirmationViewModel); return(View(result.ViewName, result)); }
public TelephoneNumberViewModel(PersonalDetailViewModel personalDetailViewModel) { PersonalDetailsViewModel = personalDetailViewModel; if (personalDetailViewModel.UserInfo != null && !string.IsNullOrEmpty(personalDetailViewModel.UserInfo.TelephoneNumber)) { _telephoneNumber = personalDetailViewModel.UserInfo.TelephoneNumber; } }
public void FromPersonalDetailViewModelToPatientDetailsConverter_Informant_true_test() { var outcome = new PersonalDetailViewModel() { UserInfo = new UserInfo() { FirstName = "Test", LastName = "User", Demography = new AgeGenderViewModel() { Age = 35, Gender = "Male" }, TelephoneNumber = "111", }, DosCheckCapacitySummaryResult = new DosCheckCapacitySummaryResult() { Success = new SuccessObject <ServiceViewModel>() { Services = new List <ServiceViewModel>() { new ServiceViewModel() { Id = 1, PostCode = "So30 2un" } } } }, SelectedServiceId = "1", AddressInformation = new LocationInfoViewModel() { PatientCurrentAddress = new CurrentAddressViewModel() { AddressLine1 = "address 1", AddressLine2 = "address 2", City = "Testity", County = "Tesux", HouseNumber = "1", Postcode = "111 111", } }, Informant = new InformantViewModel() { Forename = "Informer", Surname = "bormer", IsInformantForPatient = true } }; var result = Mapper.Map <OutcomeViewModel, PatientDetails>(outcome); Assert.AreEqual("Informer", result.Informant.Forename); Assert.AreEqual("bormer", result.Informant.Surname); Assert.AreEqual("111", result.Informant.TelephoneNumber); Assert.AreEqual(NHS111.Models.Models.Web.ITK.InformantType.NotSpecified, result.Informant.Type); }
protected override void OnNavigatedTo(NavigationEventArgs e) { int id = Template10.Services.SerializationService.SerializationService.Json.Deserialize <int>(e.Parameter?.ToString()); if (viewModel == null) { viewModel = new PersonalDetailViewModel(Convert.ToInt32(id)); DataContext = viewModel.Personal; } }
public async Task <ActionResult> SubmitCurrentAddress(PersonalDetailViewModel model, string currentAddress) { if (currentAddress == "AddressNotListed") { return(await EnterDifferentCurrentAddress(model).ConfigureAwait(false)); } model = await PopulateChosenCurrentAddress(currentAddress, model).ConfigureAwait(false); return(View("~\\Views\\PersonalDetails\\CheckAtHome.cshtml", model)); }
public void FromPersonalDetailViewModelToPatientDetailsConverter_AgeGroup_Child_test() { var outcome = new PersonalDetailViewModel() { UserInfo = new UserInfo() { FirstName = "Test", LastName = "User", Demography = new AgeGenderViewModel() { Age = 15, Gender = "Male" }, TelephoneNumber = "111", }, DosCheckCapacitySummaryResult = new DosCheckCapacitySummaryResult() { Success = new SuccessObject <ServiceViewModel>() { Services = new List <ServiceViewModel>() { new ServiceViewModel() { Id = 1, PostCode = "So30 2un" } } } }, SelectedServiceId = "1", AddressInformation = new LocationInfoViewModel() { PatientCurrentAddress = new CurrentAddressViewModel() { AddressLine1 = "address 1", AddressLine2 = "address 2", City = "Testity", County = "Tesux", HouseNumber = "1", Postcode = "111 111", } }, Informant = new InformantViewModel() { Forename = "Informer", Surname = "bormer", InformantType = InformantType.ThirdParty } }; var result = Mapper.Map <PersonalDetailViewModel, PatientDetails>(outcome); Assert.AreEqual("Child", result.AgeGroup); }
public DateOfBirthViewModel(PersonalDetailViewModel personalDetailViewModel) { PersonalDetailsViewModel = personalDetailViewModel; if (personalDetailViewModel.UserInfo != null && personalDetailViewModel.UserInfo.DoB.HasValue) { _dob = personalDetailViewModel.UserInfo.DoB; Day = personalDetailViewModel.UserInfo.DoB.Value.Day; Month = personalDetailViewModel.UserInfo.DoB.Value.Month; Year = personalDetailViewModel.UserInfo.DoB.Value.Year; } }
public async Task <StatusCodeResult> UpdatePersonalDetail(PersonalDetailViewModel viewModel) { await _profileAppService.UpdatePersonalDetail(new PersonalDetailDto { FirstName = viewModel.FirstName, LastName = viewModel.LastName, PhoneNumber = viewModel.PhoneNumber, Email = viewModel.Email }); return(StatusCode(200)); }
public async Task <ActionResult> DirectToPopulatedCurrentAddressPicker(PersonalDetailViewModel model) { model = await PopulateAddressPickerFields(model).ConfigureAwait(false); if (model.AddressInformation.PatientCurrentAddress.AddressPicker.Count > 0) { ModelState.Clear(); return(View("~\\Views\\PersonalDetails\\CurrentAddress.cshtml", model)); } else { //a location api error, or empty list return(View("~\\Views\\PersonalDetails\\CurrentAddress_NotFound.cshtml", model)); } }
public async Task <ActionResult> Confirmation(PersonalDetailViewModel model, [FromUri] bool?overrideFilterServices) { model.OutcomePage = OutcomePage.Confirmation; model = await _outcomeViewModelBuilder.ConfirmationSurveyLinkBuilder(model).ConfigureAwait(false); var modelFilterServices = overrideFilterServices.HasValue ? overrideFilterServices.Value : model.FilterServices; var availableServices = await GetServiceAvailability(model, null, modelFilterServices, null).ConfigureAwait(false); _auditLogger.LogDosResponse(model, availableServices); if (availableServices.ContainsService(model.SelectedService)) { return(await SubmitITKDataToService(model).ConfigureAwait(false)); } return(ReturnServiceUnavailableView(model, availableServices)); }
public async Task <ActionResult> SubmitChangeCurrentAddress(PersonalDetailViewModel model, string changeCurrentAddress) { switch (changeCurrentAddress) { case "changeCurrentPostcode": return(View("~\\Views\\PersonalDetails\\CurrentAddress_ChangePostcode.cshtml", model)); case "enterCurrentAddressManually": return(View("~\\Views\\PersonalDetails\\ManualAddress.cshtml", model)); case "dontKnowCurrentAddress": return(View("~\\Views\\PersonalDetails\\UnknownAddress.cshtml", model)); default: return(View("~\\Views\\PersonalDetails\\CurrentAddress_Change.cshtml", model)); } }
public async Task <ActionResult> SubmitManualAddress(PersonalDetailViewModel model) { var postcodes = await GetPostcodeResults(model.AddressInformation.PatientCurrentAddress.Postcode.Replace(" ", "")).ConfigureAwait(false); if (postcodes.ValidatedPostcodeResponse == PostcodeValidatorResponse.PostcodeNotFound) { ModelState.AddModelError("AddressInformation.PatientCurrentAddress.Postcode", new Exception()); } if (!ModelState.IsValid) { return(View("~\\Views\\PersonalDetails\\ManualAddress.cshtml", model)); } return(View("~\\Views\\PersonalDetails\\CheckAtHome.cshtml", model)); }
public IHttpActionResult PutPersonalDetail(PersonalDetailViewModel model) { try { PersonalDetail personal = _repository.Get(model.PersonalDetailID); if (personal != null) { personal.MotherName = model.MotherName; personal.FatherName = model.FatherName; personal.CellPhone = model.CellPhone; personal.DOB = model.DOB; personal.Email = model.Email; personal.FirstName = model.FirstName; personal.LastName = model.LastName; personal.NationalID = model.NationalID; personal.Photo = model.Photo; PersonalDetail result = _repository.Update(personal); // IEnumerable<Address> addresses = adRepository.GetAll(); // List<Address> filerAddress = addresses.Where(x => x.PersonalDetailID == model.PersonalDetailID).ToList(); //foreach(Address address in filerAddress) //{ // AddressViewModel viewModel = new AddressViewModel // { // PermanentAddress = address.PermanentAddress, // PresentAddress = address.PresentAddress, // }; // filerAddress.Add(address); // List<Address> result2 = adRepository.UpdateRange(filerAddress); //} return(Ok(new { obj = result, message = "Update Successfully Done!!" })); } else { return(null); } } catch (Exception ex) { BadRequest(message); throw ex; } // return CreatedAtRoute("DefaultApi", new { id = personalDetail.PersonalDetailID }, personalDetail); }
public async Task Confirmation_WithUnsuccessfulReferral_ReturnsFailureView() { var model = new PersonalDetailViewModel { SelectedServiceId = "123", OutcomeGroup = OutcomeGroup.GP, DosCheckCapacitySummaryResult = _successfulDosResponse }; _outcomeViewModelBuilder.Setup(b => b.ItkResponseBuilder(It.IsAny <OutcomeViewModel>())).ReturnsAsync(new ITKConfirmationViewModel() { ItkSendSuccess = false, ItkDuplicate = false }); _outcomeViewModelBuilder.Setup(b => b.ConfirmationSurveyLinkBuilder(It.IsAny <PersonalDetailViewModel>())) .ReturnsAsync(model); var result = await _outcomeController.Confirmation(model, null) as ViewResult; Assert.NotNull(result); Assert.AreEqual(new ReferralFailureResultViewModel(null).ViewName, result.ViewName); }
public async Task Confirmation_WithNoServicesReturned_ReturnsServiceUnavailableView() { var model = new PersonalDetailViewModel { SelectedServiceId = "123", OutcomeGroup = OutcomeGroup.GP, DosCheckCapacitySummaryResult = _successfulDosResponse }; _dosBuilder.Setup(b => b.FillCheckCapacitySummaryResult(It.IsAny <DosViewModel>(), It.IsAny <bool>(), It.IsAny <DosEndpoint?>())) .ReturnsAsync(new DosCheckCapacitySummaryResult()); _outcomeViewModelBuilder.Setup(b => b.ConfirmationSurveyLinkBuilder(It.IsAny <PersonalDetailViewModel>())) .ReturnsAsync(model); var result = await _outcomeController.Confirmation(model, null) as ViewResult; Assert.NotNull(result); Assert.AreEqual(new ServiceUnavailableReferralResultViewModel(null).ViewName, result.ViewName); }
public async Task Confirmation_Sets_OutcomePage() { var model = new PersonalDetailViewModel { SelectedServiceId = "123", OutcomeGroup = OutcomeGroup.GP, DosCheckCapacitySummaryResult = _successfulDosResponse }; _outcomeViewModelBuilder.Setup(b => b.ItkResponseBuilder(It.IsAny <OutcomeViewModel>())).ReturnsAsync(new ITKConfirmationViewModel() { ItkSendSuccess = false, ItkDuplicate = true }); _outcomeViewModelBuilder.Setup(b => b.ConfirmationSurveyLinkBuilder(It.IsAny <PersonalDetailViewModel>())) .ReturnsAsync(model); await _outcomeController.Confirmation(model, null); Assert.AreEqual(model.OutcomePage, OutcomePage.Confirmation); }
public async Task Confirmation_WithDuplicateReferral_ReturnsDuplicateView() { var model = new PersonalDetailViewModel { SelectedServiceId = "123", OutcomeGroup = OutcomeGroup.GP, DosCheckCapacitySummaryResult = _successfulDosResponse }; _outcomeViewModelBuilder.Setup(b => b.ItkResponseBuilder(It.IsAny <OutcomeViewModel>())).ReturnsAsync(new ITKConfirmationViewModel() { ItkSendSuccess = false, ItkDuplicate = true }); _outcomeViewModelBuilder.Setup(b => b.ConfirmationSurveyLinkBuilder(It.IsAny <PersonalDetailViewModel>())) .ReturnsAsync(model); var result = await _outcomeController.Confirmation(model, null) as ViewResult; Assert.NotNull(result); //Temporarily removed until status of Dupe bug is known https://trello.com/c/5hqJVLDv // Assert.AreEqual(new DuplicateReferralResultViewModel(null).ViewName, result.ViewName); Assert.AreEqual(new ReferralConfirmationResultViewModel(null).ViewName, result.ViewName); }
public async Task <ActionResult> SubmitAtHome(PersonalDetailViewModel model) { if (!ModelState.IsValid || model.AddressInformation.HomeAddressSameAsCurrentWrapper == null) { ModelState.AddModelError("AddressInformation.HomeAddressSameAsCurrentWrapper.HomeAddressSameAsCurrent", new Exception()); return(View("~\\Views\\PersonalDetails\\CheckAtHome.cshtml", model)); } if (model.AddressInformation.HomeAddressSameAsCurrentWrapper.HomeAddressSameAsCurrent == HomeAddressSameAsCurrent.Yes) { model.AddressInformation.PatientHomeAddress = model.AddressInformation.PatientCurrentAddress; return(View("~\\Views\\PersonalDetails\\ConfirmDetails.cshtml", model)); } if (model.AddressInformation.HomeAddressSameAsCurrentWrapper.HomeAddressSameAsCurrent == HomeAddressSameAsCurrent.No) { return(View("~\\Views\\PersonalDetails\\HomeAddress_Postcode.cshtml", model)); } return(View("~\\Views\\PersonalDetails\\CheckAtHome.cshtml", model)); }