public async Task <ETaskStatus> UpdateHousehold(FosteringCaseHouseholdUpdateModel model) { var completed = UpdateHouseholdIsComplete(model) ? ETaskStatus.Completed : ETaskStatus.NotCompleted; var formFields = CreateOtherPersonBuilder(ConfigurationModels.HouseholdConfigurationModel, model.AnyOtherPeopleInYourHousehold.GetValueOrDefault() ? model.OtherPeopleInYourHousehold : new List <OtherPerson>()) .AddField(EFosteringHomeVisitForm.YourHousehold.GetFormStatusFieldName(), completed.GetTaskStatus()) .AddField("listofpetsandanimals", model.DoYouHaveAnyPets.GetValueOrDefault() ? model.PetsInformation : string.Empty) .AddField("doyouhaveanypets", model.DoYouHaveAnyPets == null ? string.Empty : model.DoYouHaveAnyPets == true ? "Yes" : "No") .AddField("otherpeopleinyourhousehold", model.AnyOtherPeopleInYourHousehold == null ? string.Empty : model.AnyOtherPeopleInYourHousehold == true ? "Yes" : "No"); var updateModel = new IntegrationFormFieldsUpdateModel { CaseReference = model.CaseReference, IntegrationFormFields = formFields.Build(), IntegrationFormName = _integrationFormName }; var response = await _verintServiceGateway.UpdateCaseIntegrationFormField(updateModel); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Update household failure"); } return(completed); }
public async Task <ETaskStatus> UpdateLanguagesSpokenInYourHome(FosteringCaseLanguagesSpokenInYourHomeUpdateModel model) { var formFields = new FormFieldBuilder(); var completed = UpdateLanguagesSpokenInYourHomeIsValid(model); formFields .AddField("primarylanguage", model.PrimaryLanguage) .AddField("otherlanguages", model.OtherLanguages); formFields.AddField(EFosteringHomeVisitForm.LanguageSpokenInYourHome.GetFormStatusFieldName(), completed ? ETaskStatus.Completed.GetTaskStatus() : ETaskStatus.NotCompleted.GetTaskStatus()); var updateModel = new IntegrationFormFieldsUpdateModel { IntegrationFormName = _integrationFormName, CaseReference = model.CaseReference, IntegrationFormFields = formFields.Build() }; var response = await _verintServiceGateway .UpdateCaseIntegrationFormField(updateModel); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Update language-spoken-in-your-home failure"); } return(completed ? ETaskStatus.Completed : ETaskStatus.NotCompleted); }
public async Task <ETaskStatus> UpdateAboutYourself(FosteringCaseAboutYourselfUpdateModel model) { var completed = UpdateAboutYourselfIsValid(model.FirstApplicant); var formFields = new FormFieldBuilder() .AddField("previousname", model.FirstApplicant.EverBeenKnownByAnotherName.GetValueOrDefault() ? model.FirstApplicant.AnotherName : "") .AddField("hasanothername", model.FirstApplicant.EverBeenKnownByAnotherName == null ? "" : model.FirstApplicant.EverBeenKnownByAnotherName.ToString().ToLower()) .AddField("ethnicity", model.FirstApplicant.Ethnicity) .AddField("gender", model.FirstApplicant.Gender) .AddField("nationality", model.FirstApplicant.Nationality) .AddField("placeofbirth", model.FirstApplicant.PlaceOfBirth) .AddField("religionorfaithgroup", model.FirstApplicant.Religion); if (model.SecondApplicant != null) { completed = completed && UpdateAboutYourselfIsValid(model.SecondApplicant); formFields .AddField("previousname_2", model.SecondApplicant.EverBeenKnownByAnotherName.GetValueOrDefault() ? model.SecondApplicant.AnotherName : "") .AddField("hasanothername2", model.SecondApplicant.EverBeenKnownByAnotherName == null ? "" : model.SecondApplicant.EverBeenKnownByAnotherName.ToString().ToLower()) .AddField("ethnicity2", model.SecondApplicant.Ethnicity) .AddField("gender2", model.SecondApplicant.Gender) .AddField("placeofbirth_2", model.SecondApplicant.PlaceOfBirth) .AddField("nationality2", model.SecondApplicant.Nationality) .AddField("religionorfaithgroup2", model.SecondApplicant.Religion); } formFields.AddField(EFosteringHomeVisitForm.TellUsAboutYourself.GetFormStatusFieldName(), completed ? ETaskStatus.Completed.GetTaskStatus() : ETaskStatus.NotCompleted.GetTaskStatus()); var updateModel = new IntegrationFormFieldsUpdateModel { IntegrationFormName = _integrationFormName, CaseReference = model.CaseReference, IntegrationFormFields = formFields.Build() }; var response = await _verintServiceGateway .UpdateCaseIntegrationFormField(updateModel); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Update about-yourself failure"); } return(completed ? ETaskStatus.Completed : ETaskStatus.NotCompleted); }
public async Task UpdateIntegrationFormField_ShouldCallVerintConnection() { // Arrange var entity = new IntegrationFormFieldsUpdateModel(); // Act await _service.UpdateIntegrationFormFields(entity); // Assert _mockClient.Verify(_ => _.writeCaseEformDataAsync(It.IsAny <FWTCaseEformData>()), Times.Once); }
public async Task <ETaskStatus> UpdateReferences(FosteringCaseReferenceUpdateModel model) { var formFields = new FormFieldBuilder() .AddField("prffirstname", model.FamilyReference.FirstName) .AddField("prflastname", model.FamilyReference.LastName) .AddField("prfrelation", model.FamilyReference.RelationshipToYou) .AddField("prfyears", model.FamilyReference.NumberOfYearsKnown) .AddField("prfemail", model.FamilyReference.EmailAddress) .AddField("prfcontact", model.FamilyReference.PhoneNumber) .AddField("prf11firstname", model.FirstPersonalReference.FirstName) .AddField("prf1lastname", model.FirstPersonalReference.LastName) .AddField("prf1relation", model.FirstPersonalReference.RelationshipToYou) .AddField("prf1years", model.FirstPersonalReference.NumberOfYearsKnown) .AddField("prf1email", model.FirstPersonalReference.EmailAddress) .AddField("prf1contact", model.FirstPersonalReference.PhoneNumber) .AddField("prf2firstname", model.SecondPersonalReference.FirstName) .AddField("prf2lastname", model.SecondPersonalReference.LastName) .AddField("prf2relation", model.SecondPersonalReference.RelationshipToYou) .AddField("prf2years", model.SecondPersonalReference.NumberOfYearsKnown) .AddField("prf2email", model.SecondPersonalReference.EmailAddress) .AddField("prf2contact", model.SecondPersonalReference.PhoneNumber) .AddField(EFosteringApplicationForm.References.GetFormStatusFieldName(), ETaskStatus.Completed.GetTaskStatus()) .Build(); formFields.AddRange(AddressMapper.MapToVerintAddress(model.FamilyReference.Address, "prfaddress", "prfplaceref", "prfpostcode")); formFields.AddRange(AddressMapper.MapToVerintAddress(model.FirstPersonalReference.Address, "prf1address", "prf1placeref", "prf1postcode")); formFields.AddRange(AddressMapper.MapToVerintAddress(model.SecondPersonalReference.Address, "prf2address", "prf2placeref", "prf2postcode")); var updateModel = new IntegrationFormFieldsUpdateModel { IntegrationFormName = _applicationFormName, CaseReference = model.CaseReference, IntegrationFormFields = formFields }; var response = await _verintServiceGateway .UpdateCaseIntegrationFormField(updateModel); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Update references failure"); } return(ETaskStatus.Completed); }
public async Task UpdateIntegrationFormField_ShouldReturnError() { // Arrange var entity = new IntegrationFormFieldsUpdateModel(); _mockClient .Setup(_ => _.writeCaseEformDataAsync(It.IsAny <FWTCaseEformData>())) .ThrowsAsync(new Exception()); // Act await Assert.ThrowsAsync <Exception>(() => _service.UpdateIntegrationFormFields(entity)); // Assert _mockClient.Verify(_ => _.writeCaseEformDataAsync(It.IsAny <FWTCaseEformData>()), Times.Once); }
public async Task <IActionResult> UpdateIntegrationFormFields([FromBody] IntegrationFormFieldsUpdateModel updateEntity) { if (!ModelState.IsValid) { return(BadRequest()); } try { await _updateService.UpdateIntegrationFormFields(updateEntity); return(Ok()); } catch (Exception ex) { _logger.LogError("CaseController.UpdateIntegrationFormFields: Failed to update crm fields case", ex.InnerException); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ETaskStatus> UpdateChildrenLivingAwayFromHome(FosteringCaseChildrenLivingAwayFromHomeUpdateModel model) { var completed = UpdateChildrenLivingAwayFromHomeIsComplete(model) ? ETaskStatus.Completed : ETaskStatus.NotCompleted; var firstApplicantUnderSixteen = CreateOtherPersonBuilder(ConfigurationModels.FirstApplicantUnderSixteenConfigurationModel, model.FirstApplicant.AnyChildrenUnderSixteen.GetValueOrDefault() ? model.FirstApplicant.ChildrenUnderSixteenLivingAwayFromHome : new List <OtherPerson>(), 4) .AddField(EFosteringHomeVisitForm.ChildrenLivingAwayFromYourHome.GetFormStatusFieldName(), completed.GetTaskStatus()) .AddField("haschildrenundersixteen1", model.FirstApplicant.AnyChildrenUnderSixteen == null ? string.Empty : model.FirstApplicant.AnyChildrenUnderSixteen == true ? "yes" : "no"); var firstApplicantOverSixteen = CreateOtherPersonBuilder(ConfigurationModels.FirstApplicantOverSixteenConfigurationModel, model.FirstApplicant.AnyChildrenOverSixteen.GetValueOrDefault() ? model.FirstApplicant.ChildrenOverSixteenLivingAwayFromHome : new List <OtherPerson>(), 4) .AddField("haschildrenoversixteen1", model.FirstApplicant.AnyChildrenOverSixteen == null ? string.Empty : model.FirstApplicant.AnyChildrenOverSixteen == true ? "yes" : "no") .Build(); List <IntegrationFormField> secondApplicantUnderSixteen = new List <IntegrationFormField>(); List <IntegrationFormField> secondApplicantOverSixteen = new List <IntegrationFormField>(); if (model.SecondApplicant != null) { secondApplicantUnderSixteen = CreateOtherPersonBuilder(ConfigurationModels.SecondApplicantUnderSixteenConfigurationModel, model.SecondApplicant.AnyChildrenUnderSixteen.GetValueOrDefault() ? model.SecondApplicant.ChildrenUnderSixteenLivingAwayFromHome : new List <OtherPerson>(), 4) .AddField("haschildrenundersixteen2", model.SecondApplicant.AnyChildrenUnderSixteen == null ? string.Empty : model.SecondApplicant.AnyChildrenUnderSixteen == true ? "yes" : "no").Build(); secondApplicantOverSixteen = CreateOtherPersonBuilder(ConfigurationModels.SecondApplicantOverSixteenConfigurationModel, model.SecondApplicant.AnyChildrenOverSixteen.GetValueOrDefault() ? model.SecondApplicant.ChildrenOverSixteenLivingAwayFromHome : new List <OtherPerson>(), 4) .AddField("haschildrenoversixteen2", model.SecondApplicant.AnyChildrenOverSixteen == null ? string.Empty : model.SecondApplicant.AnyChildrenOverSixteen == true ? "yes" : "no").Build(); } var integrationFormFields = model.SecondApplicant != null?firstApplicantUnderSixteen.Build().Concat(firstApplicantOverSixteen).ToList().Concat(secondApplicantUnderSixteen).ToList().Concat(secondApplicantOverSixteen).ToList() : firstApplicantUnderSixteen.Build().Concat(firstApplicantOverSixteen).ToList(); var updateModel = new IntegrationFormFieldsUpdateModel { CaseReference = model.CaseReference, IntegrationFormFields = integrationFormFields, IntegrationFormName = _integrationFormName }; var response = await _verintServiceGateway.UpdateCaseIntegrationFormField(updateModel); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Update children living away from home failure"); } return(completed); }
public async Task UpdateIntegrationFormFields_ShouldReturn_InternalServerErrorOnException() { // Arrange var updateEntity = new IntegrationFormFieldsUpdateModel { CaseReference = "121212", IntegrationFormName = "Form_Name" }; _mockUpdateService.Setup(_ => _.UpdateIntegrationFormFields(It.IsAny <IntegrationFormFieldsUpdateModel>())) .ThrowsAsync(new Exception()); // Act var result = await _caseController.UpdateIntegrationFormFields(updateEntity); // Assert _mockUpdateService.Verify(_ => _.UpdateIntegrationFormFields(It.IsAny <IntegrationFormFieldsUpdateModel>()), Times.Once); Assert.IsType <StatusCodeResult>(result); }
public async Task UpdateIntegrationFormField_shouldCallUpdateService() { // Arrange var updateEntity = new IntegrationFormFieldsUpdateModel { CaseReference = "121212", IntegrationFormName = "Form_Name" }; _mockUpdateService.Setup(_ => _.UpdateIntegrationFormFields(It.IsAny <IntegrationFormFieldsUpdateModel>())) .ReturnsAsync(new writeCaseEformDataResponse(0)); // Act var result = await _caseController.UpdateIntegrationFormFields(updateEntity); // Assert _mockUpdateService.Verify(_ => _.UpdateIntegrationFormFields(It.IsAny <IntegrationFormFieldsUpdateModel>()), Times.Once); Assert.IsType <OkResult>(result); }
public async Task UpdateStatus(string caseId, ETaskStatus status, EFosteringHomeVisitForm form) { var formStatusFieldName = form.GetFormStatusFieldName(); var formFields = new FormFieldBuilder() .AddField(formStatusFieldName, status.GetTaskStatus()); var updateModel = new IntegrationFormFieldsUpdateModel { IntegrationFormName = _integrationFormName, CaseReference = caseId, IntegrationFormFields = formFields.Build() }; var response = await _verintServiceGateway .UpdateCaseIntegrationFormField(updateModel); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Passive update-status failure"); } }
public async Task <writeCaseEformDataResponse> UpdateIntegrationFormFields(IntegrationFormFieldsUpdateModel updateEntity) { var eformData = new FWTCaseEformData(); var formFields = new FWTEformField[0]; var caseEformInstance = new FWTCaseEformInstance { CaseReference = updateEntity.CaseReference, EformName = updateEntity.IntegrationFormName }; if (updateEntity.IntegrationFormFields != null && updateEntity.IntegrationFormFields.Any()) { formFields = new FWTEformField[updateEntity.IntegrationFormFields.Count]; for (int i = 0; i < updateEntity.IntegrationFormFields.Count; i++) { var caseFormField = new FWTEformField { FieldName = updateEntity.IntegrationFormFields[i].FormFieldName, FieldValue = updateEntity.IntegrationFormFields[i].FormFieldValue ?? string.Empty }; formFields[i] = caseFormField; } } eformData.CaseEformInstance = caseEformInstance; eformData.EformData = formFields; try { return(await _verintConnection.writeCaseEformDataAsync(eformData)); } catch (Exception e) { throw new Exception($"UpdateService: UpdateIntegrationFormField threw an exception while attempting to update EForm Data for case {updateEntity.CaseReference}, Exception: {e}"); } }
public async Task UpdateIntegrationFormField_ShouldUpdateFields() { // Arrange var writeCasecallback = new FWTCaseEformData(); var entity = new IntegrationFormFieldsUpdateModel { CaseReference = "12344", IntegrationFormFields = new List <IntegrationFormField> { new IntegrationFormField { FormFieldName = "field", FormFieldValue = "updatedValue" }, new IntegrationFormField { FormFieldName = "fieldname2", FormFieldValue = "newValue" }, } }; _mockClient .Setup(_ => _.writeCaseEformDataAsync(It.IsAny <FWTCaseEformData>())) .ReturnsAsync(new writeCaseEformDataResponse()) .Callback <FWTCaseEformData>(form => writeCasecallback = form); // Act await _service.UpdateIntegrationFormFields(entity); // Assert Assert.Equal(entity.IntegrationFormFields[0].FormFieldValue, writeCasecallback.EformData[0].FieldValue); Assert.Equal(entity.IntegrationFormFields[0].FormFieldName, writeCasecallback.EformData[0].FieldName); Assert.Equal(entity.IntegrationFormFields[1].FormFieldValue, writeCasecallback.EformData[1].FieldValue); Assert.Equal(entity.IntegrationFormFields[1].FormFieldName, writeCasecallback.EformData[1].FieldName); }
public async Task <ETaskStatus> UpdateYourEmploymentDetails(FosteringCaseYourEmploymentDetailsUpdateModel model) { var formFields = new FormFieldBuilder(); var completed = UpdateAboutEmploymentIsCompleted(model.FirstApplicant); if (model.FirstApplicant.AreYouEmployed != null) { formFields .AddField("employed", model.FirstApplicant.AreYouEmployed.Value ? "Yes" : "No") .AddField("jobtitle", model.FirstApplicant.JobTitle) .AddField("currentemployer", model.FirstApplicant.CurrentEmployer) .AddField("hoursofwork", Enum.GetName(typeof(EHoursOfWork), model.FirstApplicant.CurrentHoursOfWork)); } else { formFields .AddField("jobtitle", string.Empty) .AddField("currentemployer", string.Empty) .AddField("hoursofwork", Enum.GetName(typeof(EHoursOfWork), 0)); } if (model.SecondApplicant != null) { if (model.SecondApplicant.AreYouEmployed != null) { formFields .AddField("employed2", model.SecondApplicant.AreYouEmployed.Value ? "Yes" : "No") .AddField("jobtitle2", model.SecondApplicant.JobTitle) .AddField("currentemployer2", model.SecondApplicant.CurrentEmployer) .AddField("hoursofwork2", Enum.GetName(typeof(EHoursOfWork), model.SecondApplicant.CurrentHoursOfWork)); } else { formFields .AddField("jobtitle2", string.Empty) .AddField("currentemployer2", string.Empty) .AddField("hoursofwork2", Enum.GetName(typeof(EHoursOfWork), 0)); } completed = completed && UpdateAboutEmploymentIsCompleted(model.SecondApplicant); } formFields.AddField(EFosteringHomeVisitForm.YourEmploymentDetails.GetFormStatusFieldName(), completed ? ETaskStatus.Completed.GetTaskStatus() : ETaskStatus.NotCompleted.GetTaskStatus()); var updateModel = new IntegrationFormFieldsUpdateModel { IntegrationFormName = _integrationFormName, CaseReference = model.CaseReference, IntegrationFormFields = formFields.Build() }; var response = await _verintServiceGateway .UpdateCaseIntegrationFormField(updateModel); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Update about-your employment details failure"); } return(completed ? ETaskStatus.Completed : ETaskStatus.NotCompleted); }
public async Task <HttpResponseMessage> UpdateCaseIntegrationFormField(IntegrationFormFieldsUpdateModel content) => await PatchAsync($"{CaseEndpoint}/integration-form-fields", content);