Exemple #1
0
        public async Task <IActionResult> DirectDebitComplete(Guid id,
                                                              DirectDebitDetailsStateVm directDebitDetailsStateVm)
        {
            var directDebitDetailsVm =
                DeserialiseModel <DirectDebitDetailsVm>(directDebitDetailsStateVm.FilledInState);
            var paymentOptionsVm =
                DeserialiseModel <PaymentOptionsVm>(directDebitDetailsVm
                                                    .PaymentOptionsFilledInState);

            Debug.Assert(directDebitDetailsVm.InitialState == null,
                         "Serialisation Loop Detected - a previous step must have serialised a model that already contains InitialState");
            Debug.Assert(paymentOptionsVm.InitialState == null,
                         "Serialisation Loop Detected - a previous step must have serialised a model that already contains InitialState");

            //
            // IMPORTANT: Validates models again versus CaseFlow, to ensure no tamper or state changes since
            // started process of entering payment information
            //
            DirectDebitPlanOverviewVm directDebitPlanOverview;

            {
                var result = await _buildDirectDebitPlanOverviewVmService.ValidateAndBuild(
                    LoggedInUser, ApplicationSessionState, id, paymentOptionsVm, directDebitDetailsVm, GetCaseflowUserId());

                if (result.IsValid == false)
                {
                    return(View("ValidationFailed"));
                }

                directDebitPlanOverview = result.DirectDebitPlanOverviewVm;
                directDebitPlanOverview.UserLoggedIn = !string.IsNullOrEmpty(LoggedInUserId);
            }

            if (ApplicationSessionState.LogSetUpPlanResult)
            {
                if (directDebitDetailsVm.DiscountSelected)
                {
                    await LogDiscountDirectDebitCompleteSuccess(paymentOptionsVm);
                }
                else
                {
                    await LogDirectDebitCompleteSuccess(paymentOptionsVm);
                }

                await _directDebitPlanSetupService.CreateDirectDebitPlan(directDebitPlanOverview);

                _gtmService.RaiseDirectDebitEvent_PlanSetUp(directDebitPlanOverview, LoggedInUserId,
                                                            "Direct Debit Plan");
                ApplicationSessionState.LogSetUpPlanResult = false;
            }

            return(View(directDebitPlanOverview));
        }
Exemple #2
0
        // Generates Cancel view required when click 'Cancel' on Direct Debit confirmation page
        public IActionResult DirectDebitConfirmCancel(Guid id, DirectDebitDetailsStateVm directDebitDetailsStateVm)
        {
            // Construct model for Cancel view
            var cancelVm = new ReturnToFormVm
            {
                State                = directDebitDetailsStateVm.FilledInState,
                StateFieldName       = nameof(DirectDebitDetailsStateVm.FilledInState),
                StateType            = nameof(DirectDebitDetailsVm),
                ReturnControllerName = ControllerName,
                ReturnActionName     = nameof(DirectDebitContinue)
            };

            return(View("PaymentCancel", cancelVm));
        }
Exemple #3
0
        public async Task <IActionResult> DirectDebitContinue(Guid id,
                                                              DirectDebitDetailsStateVm directDebitDetailsStateVm)
        {
            // Restore VM from state field, so that form is as it was before moving on to next step
            var directDebitDetailsVm =
                DeserialiseModel <DirectDebitDetailsVm>(directDebitDetailsStateVm.FilledInState);

            Debug.Assert(directDebitDetailsVm.InitialState == null,
                         "Serialisation Loop Detected - InitialState should be marked as JsonIgnore");

            // Process as if user posted it
            ApplicationSessionState.LogSetUpPlanResult = true;
            return(await ProcessDirectDebitDetailsPost(id, directDebitDetailsVm));
        }
Exemple #4
0
        public IActionResult DirectDebitChange(Guid id, DirectDebitDetailsStateVm directDebitDetailsStateVm)
        {
            // Restore VM from state field, so that form is as it was before moving on to next step
            var directDebitDetailsVm =
                DeserialiseModel <DirectDebitDetailsVm>(directDebitDetailsStateVm.FilledInState);

            Debug.Assert(directDebitDetailsVm.InitialState == null,
                         "Serialisation Loop Detected - InitialState should be marked as JsonIgnore");

            // Save state for round-trip (to re-populate lists, messages etc)
            directDebitDetailsVm.InitialState = directDebitDetailsStateVm.FilledInState;

            return(View("DirectDebit", directDebitDetailsVm));
        }