diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/DocumentGeneratorStringSanitiser.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/DocumentGeneratorStringSanitiser.cs index 29d9e1ec3..76f1837c6 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/DocumentGeneratorStringSanitiser.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/DocumentGeneratorStringSanitiser.cs @@ -33,18 +33,18 @@ public static TextElement[] SanitizeTextElements(TextElement[] elements) // Utility method to create and sanitize TextElement arrays public static TextElement[] CreateTextElements(string label, string value) { - return SanitizeTextElements(new[] - { + return SanitizeTextElements( + [ new TextElement { Value = label, Bold = true }, new TextElement { Value = value } - }); + ]); } public static TextElement[] CreateSingleTextElement(string value) { - return new TextElement[] - { - new() { Value = SanitizeString(value) } - }; + return + [ + new() { Value = SanitizeString(value) } + ]; } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/RationaleGenerator.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/RationaleGenerator.cs index f155b26db..1e8a651bd 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/RationaleGenerator.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/RationaleGenerator.cs @@ -16,17 +16,17 @@ public static void AddRationale(IDocumentBuilder builder, HtbTemplate document, if (!project.AcademyTypeAndRoute.Equals(AcademyTypeAndRoutes.Sponsored)) { build.AddHeading("Rationale for the project", HeadingLevel.Two); - build.AddTable(new List - { + build.AddTable( + [ DocumentGeneratorStringSanitiser.CreateSingleTextElement(document.RationaleForProject ?? "N/A") - }); + ]); } build.AddHeading("Rationale for the trust or sponsor", HeadingLevel.Two); - build.AddTable(new List - { + build.AddTable( + [ DocumentGeneratorStringSanitiser.CreateSingleTextElement(document.RationaleForTrust ?? "N/A") - }); + ]); }); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/RisksAndIssuesGenerator.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/RisksAndIssuesGenerator.cs index 7b4d7b102..7a44f28a6 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/RisksAndIssuesGenerator.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/RisksAndIssuesGenerator.cs @@ -12,10 +12,10 @@ public static void AddRisksAndIssues(IDocumentBuilder builder, HtbTemplate docum builder.ReplacePlaceholderWithContent("RisksAndIssuesInformation", build => { build.AddHeading("Risks and issues", HeadingLevel.One); - build.AddTable(new List - { + build.AddTable( + [ DocumentGeneratorStringSanitiser.CreateSingleTextElement(document.RisksAndIssues ?? "N/A") - }); + ]); }); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolAndTrustInformationAndProjectDatesGenerator.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolAndTrustInformationAndProjectDatesGenerator.cs index 7fa8287b5..bddf76097 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolAndTrustInformationAndProjectDatesGenerator.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolAndTrustInformationAndProjectDatesGenerator.cs @@ -35,7 +35,7 @@ private static void AddAdvisoryBoardDetails(IDocumentBuilder builder, AcademyCon { List advisoryBoardDetails = new() { - DocumentGeneratorStringSanitiser.CreateTextElements("Date of advisory board", project.HeadTeacherBoardDate.ToDateString()), + DocumentGeneratorStringSanitiser.CreateTextElements("Date of advisory board", project.HeadTeacherBoardDate?.ToDateString()), DocumentGeneratorStringSanitiser.CreateTextElements("Proposed academy opening date", project.ProposedConversionDate.ToDateString()), DocumentGeneratorStringSanitiser.CreateTextElements("Previous advisory board", project.PreviousHeadTeacherBoardDate.ToDateString()) }; @@ -64,14 +64,14 @@ private static List VoluntaryRouteInfo(AcademyConversionProject p var voluntaryRouteInfo = new List { DocumentGeneratorStringSanitiser.CreateTextElements("Academy type and route", project.AcademyTypeAndRoute), - DocumentGeneratorStringSanitiser.CreateTextElements("Grant funding amount", project.ConversionSupportGrantAmount.ToMoneyString(true)), + DocumentGeneratorStringSanitiser.CreateTextElements("Grant funding amount", project.ConversionSupportGrantAmount?.ToMoneyString(true)), DocumentGeneratorStringSanitiser.CreateTextElements("Grant funding reason", project.ConversionSupportGrantChangeReason), DocumentGeneratorStringSanitiser.CreateTextElements("Recommendation", project.RecommendationForProject) }; if (project.SchoolType.ToLower().Contains("pupil referral unit")) { - voluntaryRouteInfo.Add(DocumentGeneratorStringSanitiser.CreateTextElements("Number of sites", project.ConversionSupportGrantNumberOfSites.ToString())); + voluntaryRouteInfo.Add(DocumentGeneratorStringSanitiser.CreateTextElements("Number of sites", project.ConversionSupportGrantNumberOfSites?.ToString())); } return voluntaryRouteInfo; @@ -83,17 +83,17 @@ private static List SponsoredRouteInfo(AcademyConversionProject p { DocumentGeneratorStringSanitiser.CreateTextElements("Academy type and route", project.AcademyTypeAndRoute), DocumentGeneratorStringSanitiser.CreateTextElements("Grant funding type", project.ConversionSupportGrantType), - DocumentGeneratorStringSanitiser.CreateTextElements("Grant funding amount", project.ConversionSupportGrantAmount.ToMoneyString(true)), + DocumentGeneratorStringSanitiser.CreateTextElements("Grant funding amount", project.ConversionSupportGrantAmount?.ToMoneyString(true)), DocumentGeneratorStringSanitiser.CreateTextElements("Grant funding reason", project.ConversionSupportGrantChangeReason), DocumentGeneratorStringSanitiser.CreateTextElements("Is the school applying for an EIG (Environmental Improvement Grant)?", project.ConversionSupportGrantEnvironmentalImprovementGrant), DocumentGeneratorStringSanitiser.CreateTextElements("Has the Schools Notification Mailbox (SNM) received a Form 7?", project.Form7Received), - DocumentGeneratorStringSanitiser.CreateTextElements("Date SNM received Form 7", project.Form7ReceivedDate.ToDateString()), - DocumentGeneratorStringSanitiser.CreateTextElements("Date directive academy order (DAO) pack sent", project.DaoPackSentDate.ToDateString()) + DocumentGeneratorStringSanitiser.CreateTextElements("Date SNM received Form 7", project.Form7ReceivedDate?.ToDateString()), + DocumentGeneratorStringSanitiser.CreateTextElements("Date directive academy order (DAO) pack sent", project.DaoPackSentDate?.ToDateString()) }; if (project.SchoolType.ToLower().Contains("pupil referral unit")) { - sponsoredRouteInfo.Add(DocumentGeneratorStringSanitiser.CreateTextElements("Number of sites", project.ConversionSupportGrantNumberOfSites.ToString())); + sponsoredRouteInfo.Add(DocumentGeneratorStringSanitiser.CreateTextElements("Number of sites", project.ConversionSupportGrantNumberOfSites?.ToString())); } return sponsoredRouteInfo; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolBudgetInformationGenerator.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolBudgetInformationGenerator.cs index f3bf29b4c..bf34bb104 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolBudgetInformationGenerator.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/DocumentGenerator/SchoolBudgetInformationGenerator.cs @@ -12,8 +12,8 @@ public static void AddSchoolBudgetInformation(IDocumentBuilder builder, HtbTempl builder.ReplacePlaceholderWithContent("SchoolBudgetInformation", build => { build.AddHeading("Budget information", HeadingLevel.One); - build.AddTable(new List - { + build.AddTable( + [ // Current financial year new[] { new TextElement { Value = "End of current financial year", Bold = true }, new TextElement { Value = document.EndOfCurrentFinancialYear } }, new[] { new TextElement { Value = "Forecast revenue carry forward at the end of the current financial year", Bold = true }, new TextElement { Value = document.RevenueCarryForwardAtEndMarchCurrentYear } }, @@ -23,7 +23,7 @@ public static void AddSchoolBudgetInformation(IDocumentBuilder builder, HtbTempl new[] { new TextElement { Value = "Forecast revenue carry forward at the end of the next financial year", Bold = true }, new TextElement { Value = document.ProjectedRevenueBalanceAtEndMarchNextYear } }, new[] { new TextElement { Value = "Forecast capital carry forward at the end of the next financial year", Bold = true }, new TextElement { Value = document.CapitalCarryForwardAtEndMarchNextYear } }, new[] { new TextElement { Value = "Additional information", Bold = true }, new TextElement { Value = document.SchoolBudgetInformationAdditionalInformation } }, - }); + ]); }); } }