public IActionResult AddOffenceAwaitingTrial(OffenceAwaitingTrialViewModel model, FormSection section, int id)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("AddOffenceAwaitingTrial", new { section, id }));
            }

            switch (section)
            {
            case FormSection.PrincipalAuthority:
            {
                var answerId = LicenceApplicationPostDataHandler
                               .UpsertSecurityAnswerAndLinkToParent <OffenceAwaitingTrialViewModel, OffenceAwaitingTrial,
                                                                     PrincipalAuthority>(
                    Session.GetCurrentPaId(), id, model, pa => pa.OffencesAwaitingTrial,
                    o => o.PrincipalAuthority);

                if (Session.GetCurrentPaIsDirector())
                {
                    LicenceApplicationPostDataHandler
                    .UpsertSecurityAnswerAndLinkToParent <OffenceAwaitingTrialViewModel, OffenceAwaitingTrial,
                                                          DirectorOrPartner>(
                        Session.GetCurrentDopId(), answerId, model, dop => dop.OffencesAwaitingTrial,
                        o => o.DirectorOrPartner);
                }
                break;
            }

            case FormSection.AlternativeBusinessRepresentative:
                LicenceApplicationPostDataHandler
                .UpsertSecurityAnswerAndLinkToParent <OffenceAwaitingTrialViewModel, OffenceAwaitingTrial,
                                                      AlternativeBusinessRepresentative>(
                    Session.GetCurrentAbrId(), id, model, abr => abr.OffencesAwaitingTrial,
                    o => o.AlternativeBusinessRepresentative);
                break;

            case FormSection.DirectorOrPartner:
            {
                var answerId = LicenceApplicationPostDataHandler
                               .UpsertSecurityAnswerAndLinkToParent <OffenceAwaitingTrialViewModel, OffenceAwaitingTrial,
                                                                     DirectorOrPartner>(
                    Session.GetCurrentDopId(), id, model, dop => dop.OffencesAwaitingTrial,
                    o => o.DirectorOrPartner);

                if (Session.GetCurrentDopIsPa())
                {
                    LicenceApplicationPostDataHandler
                    .UpsertSecurityAnswerAndLinkToParent <OffenceAwaitingTrialViewModel, OffenceAwaitingTrial,
                                                          PrincipalAuthority>(
                        Session.GetCurrentPaId(), answerId, model, pa => pa.OffencesAwaitingTrial,
                        o => o.PrincipalAuthority);
                }
                break;
            }

            case FormSection.NamedIndividual:
                LicenceApplicationPostDataHandler
                .UpsertSecurityAnswerAndLinkToParent <OffenceAwaitingTrialViewModel, OffenceAwaitingTrial,
                                                      NamedIndividual>(
                    Session.GetCurrentNamedIndividualId(), id, model, ni => ni.OffencesAwaitingTrial,
                    o => o.NamedIndividual);
                break;
            }

            var lastLoaded = Session.GetLoadedPage();

            return(RedirectToAction(section, lastLoaded));
        }