Example #1
0
        public static NextSection Next(BestStartGrant form, Sections completedSection)
        {
            if (IsIneligible(form, completedSection))
            {
                return new NextSection
                       {
                           Id      = form.Id,
                           Type    = NextType.Ineligible,
                           Section = null,
                       }
            }
            ;

            var index = _order.IndexOf(completedSection) + 1;

            Sections?nextSection = null;

            while (!nextSection.HasValue && index < _order.Count)
            {
                var section = _order[index];

                if (!FeatureToggles.SkipWorkInProgressSection(section))
                {
                    var strategy = SectionStrategy.For(section);

                    if (strategy.Required(form))
                    {
                        nextSection = section;
                    }
                    else
                    {
                        strategy.SkipSection(form);
                    }
                }

                index++;
            }

            return(new NextSection
            {
                Id = form.Id,
                Type = nextSection.HasValue ? NextType.Section : NextType.Complete,
                Section = nextSection,
            });
        }
Example #2
0
        public static void Populate(BsgDetail detail, Sections section, BestStartGrant form)
        {
            var index = _order.IndexOf(section) - 1;

            while (index >= 0 && !detail.PreviousSection.HasValue)
            {
                var previousSection = _order[index];

                if (!FeatureToggles.SkipWorkInProgressSection(previousSection))
                {
                    var strategy = SectionStrategy.For(previousSection);

                    if (strategy.Required(form))
                    {
                        detail.PreviousSection = previousSection;
                    }
                }

                index--;
            }

            detail.IsFinalSection = (section == _order.Last());
        }