Пример #1
0
        public async Task <IActionResult> UpdateYourEmploymentDetails(FosteringCaseYourEmploymentDetailsUpdateModel model)
        {
            try
            {
                var response = await _homeVisitService.UpdateYourEmploymentDetails(model);

                return(Ok(response));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }
 public async Task <HttpResponse <ETaskStatus> > UpdateYourEmploymentDetails(FosteringCaseYourEmploymentDetailsUpdateModel model)
 => await PatchAsync <ETaskStatus>($"{HomeVisitEndpoint}/your-employment-details", model);
        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);
        }