private static LearningProviderRates Map( LocalDomainModels.SchoolInformation schoolInformation) { LearningProviderRates toReturn = null; BaselineFunding baselineFunding = Map(schoolInformation.BaselineFunding); NotionalFunding notionalFunding = Map(schoolInformation.NotionalFunding); IllustrativeFunding illustrativeFunding = null; if (schoolInformation.IllustrativeFunding != null) { illustrativeFunding = Map(schoolInformation.IllustrativeFunding); } toReturn = new LearningProviderRates() { BaselineFunding = baselineFunding, IllustrativeFunding = illustrativeFunding, NotionalFunding = notionalFunding, }; return(toReturn); }
private static IllustrativeFunding Map( LocalDomainModels.Rates.IllustrativeFunding illustrativeFunding) { IllustrativeFunding toReturn = new IllustrativeFunding() { NewAndGrowingSchoolsTotalNffFundingIfFullyImplemented = illustrativeFunding.NewAndGrowingSchoolsTotalNffFundingIfFullyImplemented, PercentageChangeComparedToBaseline = illustrativeFunding.PercentageChangeComparedToBaseline, PercentageChangeComparedToBaselineIfFullyImplemented = illustrativeFunding.PercentageChangeComparedToBaseline, PercentageChangeInPupilLedFunding = illustrativeFunding.PercentageChangeInPupilLedFunding, PercentageChangeInPupilLedFundingIfFullyImplemented = illustrativeFunding.PercentageChangeInPupilLedFundingIfFullyImplemented, PercentageChangeInPupilLedFundingPerPupil = illustrativeFunding.PercentageChangeInPupilLedFundingPerPupil, TotalNffFunding = illustrativeFunding.TotalNffFunding, TotalNffFundingIfFullyImplemented = illustrativeFunding.TotalNffFundingIfFullyImplemented, TotalNffFundingIfFullyImplementedPerPupil = illustrativeFunding.TotalNffFundingIfFullyImplementedPerPupil, }; return(toReturn); }
/// <inheritdoc /> public override async Task CreateAsync( int year, DomainModels.SchoolInformation schoolInformation, CancellationToken cancellationToken) { if (schoolInformation == null) { throw new ArgumentNullException(nameof(schoolInformation)); } if (!schoolInformation.Urn.HasValue) { throw new DataException( $"A {nameof(schoolInformation.Urn)} is required in " + $"order to insert."); } long urn = schoolInformation.Urn.Value; List <ModelsBase> modelsBases = new List <ModelsBase> { this.Map <DomainModels.SchoolInformation, SchoolInformation>( year, urn, schoolInformation), this.Map <DomainModels.Rates.BaselineFunding, BaselineFunding>( year, urn, schoolInformation.BaselineFunding), this.Map <DomainModels.Rates.NotionalFunding, NotionalFunding>( year, urn, schoolInformation.NotionalFunding), }; if (schoolInformation.IllustrativeFunding != null) { IllustrativeFunding illustrativeFunding = this.Map <DomainModels.Rates.IllustrativeFunding, IllustrativeFunding>( year, urn, schoolInformation.IllustrativeFunding); modelsBases.Add(illustrativeFunding); } try { await this.CreateAsync( modelsBases, cancellationToken) .ConfigureAwait(false); } catch (StorageException storageException) { this.loggerWrapper.Error( $"Note! Exception thrown whilst trying to insert record " + $"for {nameof(year)} {year}, {nameof(urn)} {urn}.", storageException); } }