コード例 #1
0
        public NextSection AddExpectedChildren(ExpectedChildren expectedChildren)
        {
            Validate(expectedChildren);

            ExpectedChildren = expectedChildren;
            return(OnSectionCompleted(Sections.ExpectedChildren));
        }
コード例 #2
0
 public static ExpectedChildren NoBabyExpected(this ExpectedChildren expectedChildren)
 {
     expectedChildren.IsBabyExpected    = false;
     expectedChildren.ExpectancyDate    = null;
     expectedChildren.ExpectedBabyCount = null;
     return(expectedChildren);
 }
コード例 #3
0
 public static ExpectedChildren ExpectedBabyCount(this ExpectedChildren expectedChildren, int?babyCount)
 {
     expectedChildren.IsBabyExpected          = babyCount > 0;
     expectedChildren.ExpectancyDate          = DomainRegistry.NowUtc().Date.AddDays(100);
     expectedChildren.IsMoreThan1BabyExpected = babyCount > 1;
     expectedChildren.ExpectedBabyCount       = babyCount > 1 ? babyCount.Value : (int?)null;
     return(expectedChildren);
 }
コード例 #4
0
        /// <summary>
        /// Get the required elements - elements which minOccurs > 0.
        /// </summary>
        /// <returns>Required elements in this particle.</returns>
        public ExpectedChildren GetRequiredElements()
        {
            var requiredElements = new ExpectedChildren();

            GetRequiredElements(requiredElements);

            return(requiredElements);
        }
コード例 #5
0
        public static ExpectedChildren NewValid(Action <ExpectedChildren> mutator = null)
        {
            var expectedChildren = new ExpectedChildren();

            BestStartGrantForms.Dto.ExpectedChildrenBuilder.Populate(expectedChildren);
            mutator?.Invoke(expectedChildren);
            return(expectedChildren);
        }
コード例 #6
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <returns>Expected elements in this particle.</returns>
        public ExpectedChildren GetExpectedElements()
        {
            var expectedElements = new ExpectedChildren();

            GetExpectedElements(expectedElements);

            return(expectedElements);
        }
コード例 #7
0
        internal static string GetExpectedChildrenMessage(OpenXmlElement parent, ExpectedChildren expectedChildrenIds)
        {
            if (expectedChildrenIds is not null)
            {
                return(expectedChildrenIds.GetExpectedChildrenMessage(parent));
            }

            return(string.Empty);
        }
コード例 #8
0
 private ActionResult ExpectedChildren_Render(string formId, ExpectedChildren details)
 {
     return(NavigableView <ExpectedChildrenModel>(formId, Sections.ExpectedChildren, (m, f) =>
     {
         m.TitlePrefix = BsgText.TitlePrefix();
         m.Title = BsgText.ExpectedChildrenTitle();
         m.ExpectedChildren = details ?? f.ExpectedChildren;
     }));
 }
コード例 #9
0
        public static ExpectedChildren Populate(ExpectedChildren expectedChildren, Action <ExpectedChildren> mutator = null)
        {
            expectedChildren.IsBabyExpected          = true;
            expectedChildren.ExpectancyDate          = DomainRegistry.NowUtc().Date + TimeSpan.FromDays(100);
            expectedChildren.IsMoreThan1BabyExpected = true;
            expectedChildren.ExpectedBabyCount       = 2;

            mutator?.Invoke(expectedChildren);

            return(expectedChildren);
        }
コード例 #10
0
 private ActionResult ExpectedChildren_Render(string formId, ExpectedChildren details)
 {
     return(NavigableView <ExpectedChildrenModel>(formId, Bsg.BsgViews.ExpectedChildren, Sections.ExpectedChildren, (m, f) =>
     {
         m.TitlePrefix = CocText.TitlePrefix();
         m.Title = "Expected baby";
         m.ExpectedChildren = details ?? f.ExpectedChildren ?? new ExpectedChildren();
         m.ExpectedChildren.IsBabyExpected = true;
         m.HideIsBabyExpected = true;
     }));
 }
コード例 #11
0
        public ActionResult ExpectedChildren(string id, ExpectedChildren expectedChildren)
        {
            var cmd = new AddExpectedChildren
            {
                FormId           = id,
                ExpectedChildren = expectedChildren,
            };

            return(Exec(cmd,
                        success: next => RedirectNext(next),
                        failure: () => ExpectedChildren_Render(id, expectedChildren)));
        }
コード例 #12
0
        public NextSection AddExpectedChildren(ExpectedChildren expectedChildren)
        {
            if (expectedChildren.IsBabyExpected == false)
            {
                throw new DomainException("Must indicate having a baby in Change of Circumstances");
            }

            new BestStartGrantForms.Commands.Validate {
                ExpectedChildren = expectedChildren
            }.Execute();

            ExpectedChildren = expectedChildren;
            return(OnSectionCompleted(Sections.ExpectedChildren));
        }
コード例 #13
0
        internal static void Validate(ExpectedChildren expectedChildren)
        {
            var ctx = new ValidationContext <ExpectedChildren>(expectedChildren);

            ctx.Required(c => c.IsBabyExpected, "Please indicate if you are expecting a baby");

            if (expectedChildren.IsBabyExpected == false)
            {
                expectedChildren.ExpectancyDate          = null;
                expectedChildren.IsMoreThan1BabyExpected = null;
                expectedChildren.ExpectedBabyCount       = null;
            }

            if (expectedChildren.IsBabyExpected == true)
            {
                ctx.Required(m => m.ExpectancyDate, "Please supply the date the baby is due");

                if (expectedChildren.ExpectancyDate.HasValue)
                {
                    ctx.InFuture(m => m.ExpectancyDate, "Please supply a due date in the future");
                }

                ctx.Required(m => m.IsMoreThan1BabyExpected, "Please indicate if more than one baby is expected");

                if (expectedChildren.IsMoreThan1BabyExpected == false)
                {
                    expectedChildren.ExpectedBabyCount = null;
                }

                if (expectedChildren.IsMoreThan1BabyExpected == true)
                {
                    ctx.Required(m => m.ExpectedBabyCount, "Please supply how many babies are expected");

                    ctx.Custom(m => m.ExpectedBabyCount, babyCount =>
                               babyCount.HasValue && (babyCount.Value < 2 || babyCount.Value > 10)
                            ? "Please supply a number of babies between 2 and 10"
                            : null);
                }
            }

            ctx.ThrowIfError();
        }
コード例 #14
0
 public static ExpectedChildren Invalid(this ExpectedChildren expectedChildren)
 {
     expectedChildren.IsBabyExpected = null;
     return(expectedChildren);
 }
コード例 #15
0
 /// <summary>
 /// Get the expected elements - elements which minOccurs >= 0.
 /// </summary>
 /// <param name="result"></param>
 /// <returns>True if there are expected elements in this particle.</returns>
 public virtual bool GetExpectedElements(ExpectedChildren result)
 {
     return(false);
 }