/// <summary>
        /// get (the) touchpoint id from (the) Postcode
        /// </summary>
        /// <param name="theCandidate">the candidate</param>
        /// <param name="usingScope">using (the logging) scope</param>
        /// <returns>the LAD code</returns>
        public async Task <string> GetTouchpointIDFromPostcode(string theCandidate, IScopeLoggingContext usingScope)
        {
            await usingScope.EnterMethod();

            await usingScope.Information($"seeking postcode '{theCandidate}'");

            var result = await Postcode.LookupAsync(theCandidate);

            It.IsNull(result)
            .AsGuard <InvalidPostcodeException>(theCandidate);
            It.IsEmpty(result.Postcode)
            .AsGuard <InvalidPostcodeException>(theCandidate);

            await usingScope.Information($"found postcode for '{result.Postcode}'");

            await usingScope.Information($"seeking local authority '{result.Codes.AdminDistrict}'");

            var authority = await Authority.Get(result.Codes.AdminDistrict);

            await usingScope.Information($"found local authority '{authority.LADCode}'");

            await usingScope.ExitMethod();

            return(authority.TouchpointID);
        }
        /// <summary>
        /// Imports the file...
        /// </summary>
        /// <param name="usingInstance">using instance.</param>
        /// <param name="getFileName">get the name of the file</param>
        /// <param name="andConfirmAnyChallenge">and confirm any challenge.</param>
        /// <returns>
        /// the current task
        /// </returns>
        public async Task Import(string usingInstance, string usingDatabase, string dbUser, string dbPassword, Func <string> getFileName, Func <string, bool> andConfirmAnyChallenge)
        {
            It.IsNull(getFileName)
            .AsGuard <ArgumentNullException>(nameof(getFileName));

            await Handler.RunAsyncOperation <Localised>(async() =>
            {
                Emitter.Publish("Selecting file...");

                var inputFilePath = getFileName();

                It.IsEmpty(inputFilePath)
                .AsGuard <OperationCanceledException, CommonLocalised>(CommonLocalised.CanceledOperation);

                //var candidateSourceName = Path.GetFileNameWithoutExtension(inputFilePath);


                // check for DB overwrite...
                Emitter.Publish("Checking for risk of overwrite...");

                var master = Provider.ConnectionToMaster(usingInstance, usingDatabase, dbUser, dbPassword);

                //if (Context.DataStoreExists(candidateSourceName, master))
                //{
                //    var format = Locals.GetString(Localised.AboutToOverwriteDBFormat);
                //    var msg = Format.String(format, candidateSourceName);
                //    (!andConfirmAnyChallenge(msg))
                //        .AsGuard<OperationCanceledException, CommonLocalised>(CommonLocalised.CanceledOperation);
                //}

                var source = Provider.ConnectionToSource(usingInstance, usingDatabase, dbUser, dbPassword);

                await BulkLoader.Load(source, master, inputFilePath);
            });
        }
示例#3
0
        /// <summary>
        /// Retrieves the ons postcodes asynchronously.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>a set of ons postcode records</returns>
        public async Task <IReadOnlyCollection <IONSPostcode> > RetrieveONSPostcodesAsync(CancellationToken cancellationToken)
        {
            return(await Task.Run(
                       () =>
            {
                var message = _messageCache.Item;
                It.IsNull(message)
                .AsGuard <ArgumentNullException>(nameof(message));

                var deliveries = message.Learners
                                 .AsSafeReadOnlyList()
                                 .SelectMany(x => x.LearningDeliveries.AsSafeReadOnlyList())
                                 .AsSafeReadOnlyList();
                var uniquePostcodes = GetUniqueDeliveryLocationPostcodesFrom(deliveries).ToCaseInsensitiveHashSet();

                return _postcodes.ONS_Postcodes
                .Where(p => uniquePostcodes.Contains(p.Postcode))
                .AsEnumerable()
                .Select(p => new ONSPostcode
                {
                    Postcode = p.Postcode,
                    EffectiveFrom = p.EffectiveFrom,
                    EffectiveTo = p.EffectiveTo,
                    LocalAuthority = p.LocalAuthority,
                    Lep1 = p.Lep1,
                    Lep2 = p.Lep2,
                    Termination = GetEndOfMonthDateFromYearMonthString(p.Termination)
                })
                .AsSafeReadOnlyList();
            }, cancellationToken));
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LearnDelFAMType_66Rule" /> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        /// <param name="larsData">The lars data.</param>
        /// <param name="derivedData07">The derived data 07 rule.</param>
        /// <param name="derivedData21">The derived data 21 rule.</param>
        /// <param name="derivedData28">The derived data 28 rule.</param>
        /// <param name="derivedData29">The derived data 29 rule.</param>
        public LearnDelFAMType_66Rule(
            IValidationErrorHandler validationErrorHandler,
            ILARSDataService larsData,
            IDD07 derivedData07,
            IDerivedData_21Rule derivedData21,
            IDerivedData_28Rule derivedData28,
            IDerivedData_29Rule derivedData29)
        {
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));
            It.IsNull(larsData)
            .AsGuard <ArgumentNullException>(nameof(larsData));
            It.IsNull(derivedData07)
            .AsGuard <ArgumentNullException>(nameof(derivedData07));
            It.IsNull(derivedData21)
            .AsGuard <ArgumentNullException>(nameof(derivedData21));
            It.IsNull(derivedData28)
            .AsGuard <ArgumentNullException>(nameof(derivedData28));
            It.IsNull(derivedData29)
            .AsGuard <ArgumentNullException>(nameof(derivedData29));

            _messageHandler = validationErrorHandler;
            _larsData       = larsData;
            _derivedData07  = derivedData07;
            _derivedData21  = derivedData21;
            _derivedData28  = derivedData28;
            _derivedData29  = derivedData29;
        }
示例#5
0
        /// <summary>
        /// Determines whether [is adult funded unemployed with other state benefits] [the specified candidate].
        /// </summary>
        /// <param name="candidate">The candidate.</param>
        /// <returns>
        ///   <c>true</c> if [is adult funded unemployed with other state benefits] [the specified candidate]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsAdultFundedUnemployedWithOtherStateBenefits(ILearner candidate)
        {
            It.IsNull(candidate)
            .AsGuard <ArgumentNullException>(nameof(candidate));

            var lds = candidate.LearningDeliveries.AsSafeReadOnlyList();
            var les = candidate.LearnerEmploymentStatuses.AsSafeReadOnlyList();

            /*
             *  if
             *      // is adult skills
             *      LearningDelivery.FundModel = 35
             *
             *      //  is umemployed (not employed, seeking and available or otherwise)
             *      and     LearnerEmploymentStatus.EmpStat = 11 or 12 for the latest Employment Status on (or before) the LearningDelivery.LearnStartDate
             *
             *              // in receipt of another benefit.
             *      and     ((Monitoring.EmploymentStatus.ESMType = BSI and Monitoring.EmploymentStatus.ESMCode = 3)
             *              or
             *              // in receipt of universal credit.
             *              (Monitoring.EmploymentStatus.ESMType = BSI and Monitoring.EmploymentStatus.ESMCode = 4
             *              // is learning delivery monitored
             *              and LearningDeliveryFAM.LearnDelFAMType = LDM
             *              // and not mandated to skills training
             *              and LearningDeliveryFAM.LearnDelFAMCode <> 318))
             *
             *          set to Y,
             *          otherwise set to N
             */

            return(lds.Any(d =>
                           IsAdultSkills(d) &&
                           IsNotEmployed(les, d, () => ConfirmMonitoringAndMandation(d.LearningDeliveryFAMs.AsSafeReadOnlyList()))));
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriorLearnFundAdj_02Rule"/> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        public PriorLearnFundAdj_02Rule(IValidationErrorHandler validationErrorHandler)
        {
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));

            _messageHandler = validationErrorHandler;
        }
示例#7
0
        /// <summary>
        /// initialises an instance of the <see cref="PostcodesClientWrapper"/>
        /// using the principle of poor man's DI
        /// </summary>
        /// <param name="theClient">the client</param>
        public PostcodesClientWrapper(IPostcodesIOClient theClient)
        {
            It.IsNull(theClient)
            .AsGuard <ArgumentNullException>(nameof(theClient));

            Client = theClient;
        }
        /// <summary>
        /// create an instance of <see cref="AreaRoutingDetailManagementFunctionAdapter"/>
        /// </summary>
        /// <param name="routingDetails">the storage provider</param>
        /// <param name="responseHelper">the response helper</param>
        /// <param name="faultResponses">the fault responses (provider)</param>
        /// <param name="safeOperations">the safe operations (provider)</param>
        /// <param name="analyser">the expression analyser</param>
        /// <param name="actions">the expression action provider</param>
        public AreaRoutingDetailManagementFunctionAdapter(
            IHttpResponseMessageHelper responseHelper,
            IProvideFaultResponses faultResponses,
            IProvideSafeOperations safeOperations,
            IStoreAreaRoutingDetails routingDetails,
            IValidateRoutingDetails validator,
            IAnalyseExpresssions analyser,
            IProvideExpressionActions actions)
        {
            It.IsNull(responseHelper)
            .AsGuard <ArgumentNullException>(nameof(responseHelper));
            It.IsNull(faultResponses)
            .AsGuard <ArgumentNullException>(nameof(faultResponses));
            It.IsNull(safeOperations)
            .AsGuard <ArgumentNullException>(nameof(safeOperations));
            It.IsNull(routingDetails)
            .AsGuard <ArgumentNullException>(nameof(routingDetails));
            It.IsNull(validator)
            .AsGuard <ArgumentNullException>(nameof(validator));
            It.IsNull(analyser)
            .AsGuard <ArgumentNullException>(nameof(analyser));
            It.IsNull(actions)
            .AsGuard <ArgumentNullException>(nameof(actions));

            Respond        = responseHelper;
            Faults         = faultResponses;
            SafeOperations = safeOperations;
            RoutingDetails = routingDetails;
            RoutingDetail  = validator;
            Analyser       = analyser;
            Actions        = actions;
        }
示例#9
0
        /// <summary>
        /// Exports to ILR
        /// </summary>
        /// <param name="usingSource">using source.</param>
        /// <param name="inContext">in context.</param>
        /// <param name="forProvider">for provider.</param>
        /// <returns>
        /// the currently running task
        /// </returns>
        public async Task Export(IInputDataSource usingSource, IConnectionDetail inContext, int forProvider)
        {
            It.IsNull(usingSource)
            .AsGuard <ArgumentNullException>(nameof(usingSource));
            It.IsNull(inContext)
            .AsGuard <ArgumentNullException>(nameof(inContext));

            await Task.Run(async() =>
            {
                using (Timing.BeginScope($"Export file for {forProvider}"))
                {
                    var schema       = Schemas.GetSchema(usingSource.OperatingYear);
                    var schemaPath   = Path.Combine(Location.OfAssets, schema.Message);
                    var templatePath = Path.Combine(Location.OfAssets, schema.BulkExport);
                    var candidate    = await FileManager.Load(templatePath);
                    var batch        = Batches.GetBatch(BatchProcessName.ExportSourceDataToILRFile, usingSource.OperatingYear);

                    candidate = candidate.Replace(Token.ForNamespace, schema.Namespace);

                    batch.Scripts
                    .ForEach(script => RunScript(script, inContext, forProvider, ref candidate));

                    var outputPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "exportILR.xml");
                    await FileManager.Save(outputPath, candidate);
                    await StripEmptyTags(outputPath);

                    Emitter.Publish(Indentation.FirstLevel, CommonLocalised.Completed);

                    //(!await Validator.IsValid(outputPath, schemaPath))
                    //    .AsGuard<OperationCanceledException, CommonLocalised>(CommonLocalised.SchemaValidationFailed);
                }
            });
        }
示例#10
0
        /// <summary>
        /// initialsies an instance of <see cref="LocalAuthorityValidator"/>
        /// </summary>
        /// <param name="message">the message (factory)</param>
        public LocalAuthorityValidator(ICreateValidationMessageContent message)
        {
            It.IsNull(message)
            .AsGuard <ArgumentNullException>(nameof(message));

            Message = message;
        }
        /// <summary>
        /// process, get (the) area routing detail for...
        /// </summary>
        /// <param name="theTouchpointID">the touchpoint id</param>
        /// <param name="inScope">in logging scope</param>
        /// <returns>the currently running task containing the response message (success only)</returns>
        internal async Task <HttpResponseMessage> ProcessGetAreaRoutingDetailFor(string theTouchpointID, IScopeLoggingContext inScope)
        {
            await inScope.EnterMethod();

            It.IsEmpty(theTouchpointID)
            .AsGuard <MalformedRequestException>();

            await inScope.Information($"seeking the routing details: '{theTouchpointID}'");

            var theDetail = await RoutingDetails.Get(theTouchpointID);

            It.IsNull(theDetail)
            .AsGuard <MalformedRequestException>(theTouchpointID);

            await inScope.Information($"candidate search complete: '{theDetail.TouchpointID}'");

            await inScope.Information($"preparing response...");

            var response = Respond.Ok().SetContent(theDetail);

            await inScope.Information($"preparation complete...");

            await inScope.ExitMethod();

            return(response);
        }
        /// <summary>
        /// Validates the specified object.
        /// </summary>
        /// <param name="objectToValidate">The object to validate.</param>
        public void Validate(ILearner objectToValidate)
        {
            It.IsNull(objectToValidate)
            .AsGuard <ArgumentNullException>(nameof(objectToValidate));

            var learnRefNumber = objectToValidate.LearnRefNumber;

            var fromDeliveries = objectToValidate.LearningDeliveries.AsSafeReadOnlyList();
            var qualifyingAim  = GetQualifyingdAimOn(fromDeliveries);

            if (It.IsNull(qualifyingAim))
            {
                return;
            }

            var eligibilities = GetEligibilityRulesFor(qualifyingAim);

            if (It.IsEmpty(eligibilities))
            {
                return;
            }

            var fromEmployments = objectToValidate.LearnerEmploymentStatuses.AsSafeReadOnlyList();
            var employment      = _check.GetEmploymentStatusOn(qualifyingAim.LearnStartDate, fromEmployments);

            if (It.IsNull(employment))
            {
                return;
            }

            if (IsNotValid(eligibilities, employment))
            {
                RaiseValidationMessage(learnRefNumber, qualifyingAim, employment);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DateEmpStatApp_02Rule" /> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        /// <param name="yearData">The year data.</param>
        public DateEmpStatApp_02Rule(IValidationErrorHandler validationErrorHandler)
        {
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));

            _messageHandler = validationErrorHandler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UKPRN_08Rule"/> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        /// <param name="fileDataService">The file data service.</param>
        /// <param name="academicYearDataService">The academic year data service.</param>
        /// <param name="commonOperations">The common operations.</param>
        /// <param name="fcsDataService">The FCS data service.</param>
        public UKPRN_08Rule(
            IValidationErrorHandler validationErrorHandler,
            IFileDataService fileDataService,
            IAcademicYearDataService academicYearDataService,
            IProvideRuleCommonOperations commonOperations,
            IFCSDataService fcsDataService)
            : base(validationErrorHandler, RuleNameConstants.UKPRN_08)
        {
            // this check should be in the base class
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));

            It.IsNull(fileDataService)
            .AsGuard <ArgumentNullException>(nameof(fileDataService));
            It.IsNull(academicYearDataService)
            .AsGuard <ArgumentNullException>(nameof(academicYearDataService));
            It.IsNull(commonOperations)
            .AsGuard <ArgumentNullException>(nameof(commonOperations));
            It.IsNull(fcsDataService)
            .AsGuard <ArgumentNullException>(nameof(fcsDataService));

            _fileDataService         = fileDataService;
            _academicYearDataService = academicYearDataService;
            _check          = commonOperations;
            _fcsDataService = fcsDataService;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SWSSupAimId_01Rule"/> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        public SWSSupAimId_01Rule(IValidationErrorHandler validationErrorHandler)
        {
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));

            _messageHandler = validationErrorHandler;
        }
示例#16
0
        /// <summary>
        /// initialises an instance of <see cref="DocumentClientWrapper"/>
        /// using the principle of poor man's DI
        /// </summary>
        /// <param name="theClient">the client</param>
        public DocumentClientWrapper(IDocumentClient theClient)
        {
            It.IsNull(theClient)
            .AsGuard <ArgumentNullException>(nameof(theClient));

            Client = theClient;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WorkPlaceStartDate_01Rule"/> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        public WorkPlaceStartDate_01Rule(IValidationErrorHandler validationErrorHandler)
        {
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));

            _messageHandler = validationErrorHandler;
        }
        /// <summary>
        /// initalises a new instance of the <see cref="LoggingContextScopeFactory"/>
        /// </summary>
        /// <param name="log">the microsoft log</param>
        /// <param name="logHelper">the DFC logging helper</param>
        public LoggingContextScopeFactory(ILoggerHelper logHelper)
        {
            It.IsNull(logHelper)
            .AsGuard <ArgumentNullException>(nameof(logHelper));

            LoggerHelper = logHelper;
        }
示例#19
0
        /// <summary>
        /// Determines whether [is adult skills unemployed with benefits] [the specified candidate].
        /// </summary>
        /// <param name="candidate">The candidate.</param>
        /// <returns>
        ///   <c>true</c> if [is adult skills unemployed with benefits] [the specified candidate]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsAdultFundedUnemployedWithBenefits(ILearner candidate)
        {
            It.IsNull(candidate)
            .AsGuard <ArgumentNullException>(nameof(candidate));

            /*
             *  if
             *      // is adult skills
             *      LearningDelivery.FundModel = 35
             *      // and has valid employment status
             *      and LearnerEmploymentStatus.EmpStat = 10, 11, 12 or 98
             *      // and in receipt of support at the time of starting the learning aim
             *      and (EmploymentStatusMonitoring.ESMType = BSI and EmploymentStatusMonitoring.ESMCode = 1 or 2)
             *          (for the learner's Employment status on the LearningDelivery.LearnStartDate of the learning aim)
             *  or
             *      // or is not employed, and in receipt of benefits
             *      LearnerEmploymentStatus.EmpStat = 11 or 12
             *      and (EmploymentStatusMonitoring.ESMType = BSI and EmploymentStatusMonitoring.ESMCode = 3 or 4)
             *  or
             *      // or is employed with workng short hours and in receipt of support
             *      LearnerEmploymentStatus.EmpStat = 10
             *      and (EmploymentStatusMonitoring.ESMType = EII and EmploymentStatusMonitoring.ESMCode = 2, 5 or 6)
             *      and (EmploymentStatusMonitoring.ESMType = BSI and EmploymentStatusMonitoring.ESMCode = 3 or 4)
             *          set to Y,
             *          otherwise set to N
             */

            return(IsValidWithEmploymentSupport(candidate) ||
                   IsNotEmployedWithBenefits(candidate) ||
                   IsEmployedWithSupport(candidate));
        }
示例#20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DerivedData_21Rule"/> class.
        /// </summary>
        /// <param name="commonOperations">The common operations.</param>
        public DerivedData_21Rule(IProvideRuleCommonOperations commonOperations)
        {
            It.IsNull(commonOperations)
            .AsGuard <ArgumentNullException>(nameof(commonOperations));

            _check = commonOperations;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LearnDelFAMType_62Rule" /> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        /// <param name="larsData">The lars data.</param>
        /// <param name="derivedData07">The derived data 07 rule.</param>
        /// <param name="derivedData21">The derived data 21 rule.</param>
        /// <param name="derivedData28">The derived data 28 rule.</param>
        /// <param name="derivedData29">The derived data 29 rule.</param>
        public LearnDelFAMType_62Rule(
            IValidationErrorHandler validationErrorHandler,
            ILARSDataService larsData,
            IDerivedData_07Rule derivedData07,
            IDerivedData_21Rule derivedData21,
            IDerivedData_28Rule derivedData28,
            IDerivedData_29Rule derivedData29)
            : base(validationErrorHandler, RuleNameConstants.LearnDelFAMType_62)
        {
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));
            It.IsNull(larsData)
            .AsGuard <ArgumentNullException>(nameof(larsData));
            It.IsNull(derivedData07)
            .AsGuard <ArgumentNullException>(nameof(derivedData07));
            It.IsNull(derivedData21)
            .AsGuard <ArgumentNullException>(nameof(derivedData21));
            It.IsNull(derivedData28)
            .AsGuard <ArgumentNullException>(nameof(derivedData28));
            It.IsNull(derivedData29)
            .AsGuard <ArgumentNullException>(nameof(derivedData29));

            _larsData      = larsData;
            _derivedData07 = derivedData07;
            _derivedData21 = derivedData21;
            _derivedData28 = derivedData28;
            _derivedData29 = derivedData29;
        }
        /// <summary>
        /// Runs...
        /// </summary>
        /// <param name="thisBatchFile">this batch file.</param>
        /// <param name="inThisContext">The in this context.</param>
        /// <param name="withSupplementaryTokenReplacements">with supplementary token replacements.</param>
        public void Run(
            ISQLBatchScript thisBatchScript,
            IConnectionDetail inThisContext,
            Func <string, string> withSupplementaryTokenReplacements)
        {
            It.IsNull(thisBatchScript)
            .AsGuard <ArgumentNullException>(nameof(thisBatchScript));
            It.IsNull(inThisContext)
            .AsGuard <ArgumentNullException>(nameof(inThisContext));

            if (It.IsInRange(thisBatchScript.Type, TypeOfBatchScript.Ignored))
            {
                return;
            }

            Emitter.Publish(Indentation.FirstLevel, $"Running: '{thisBatchScript.Description}'");

            if (It.IsInRange(thisBatchScript.Type, TypeOfBatchScript.Statement))
            {
                var content = Pseudonyms.ReplaceTokensIn(thisBatchScript.Command, withSupplementaryTokenReplacements);
                UsingConnection(inThisContext, x => RunCommand(content, x));
                return;
            }

            var batches = GetSQLOperations(thisBatchScript.Command, withSupplementaryTokenReplacements);

            Emitter.Publish(Indentation.FirstLevel, $"Batch contains {batches.Count} statement{(batches.Count > 1 ? "s" : string.Empty)}.");

            Run(batches.AsSafeReadOnlyList(), inThisContext);
        }
        /// <summary>
        /// initialise an instance of the <see cref="ApiDefinitionFunction"/>
        /// </summary>
        /// <param name="generator">(the swagger document) generator</param>
        public ApiDefinitionFunction(ISwaggerDocumentGenerator generator)
        {
            It.IsNull(generator)
            .AsGuard <ArgumentNullException>(nameof(generator));

            Generator = generator;
        }
        /// <summary>
        /// From the data reader.
        /// this should work if property names match column names
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="reader">The dr.</param>
        /// <returns>a collection of T</returns>
        public TContract FromDataReader <TReturn, TContract>(IDataReader reader, string[] propertyNames)
            where TReturn : class, TContract, new()
        {
            It.IsNull(reader)
            .AsGuard <ArgumentNullException>(nameof(reader));

            var instance = default(TReturn);

            if (reader.Read())
            {
                instance = new TReturn();

                propertyNames.ForEach(name =>
                {
                    var property      = typeof(TReturn).GetProperty(name);
                    var propertyValue = GetSafe(reader, name, property.GetValue(instance));

                    if (It.Has(property))
                    {
                        property.SetValue(instance, propertyValue);
                    }
                });
            }

            return(instance);
        }
        /// <summary>
        /// initialsies an instance of <see cref="RoutingDetailValidator"/>
        /// </summary>
        /// <param name="message">the message (factory)</param>
        public RoutingDetailValidator(ICreateValidationMessageContent message)
        {
            It.IsNull(message)
            .AsGuard <ArgumentNullException>(nameof(message));

            Message = message;
        }
        /// <summary>
        /// Gets the list.
        /// </summary>
        /// <typeparam name="TReturn">The type of the return.</typeparam>
        /// <param name="usingThisCommand">using this command.</param>
        /// <param name="inThisContext">in this context.</param>
        /// <returns>
        /// an list of type <typeparamref name="TReturn" />
        /// </returns>
        public ICollection <TReturn> GetList <TReturn>(string usingThisCommand, IConnectionDetail inThisContext)
        {
            It.IsEmpty(usingThisCommand)
            .AsGuard <ArgumentNullException>(nameof(usingThisCommand));
            It.IsNull(inThisContext)
            .AsGuard <ArgumentNullException>(nameof(inThisContext));

            return(UsingConnection(inThisContext, x =>
            {
                var tempList = Collection.Empty <TReturn>();
                using (var cmd = CreateCommand(usingThisCommand, x))
                {
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var candidate = reader.GetValue(0);

                            tempList.Add(GetValue <TReturn>(candidate));
                        }
                    }
                }

                return tempList;
            }));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LearnDelFAMType_01Rule"/> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        public LearnDelFAMType_01Rule(IValidationErrorHandler validationErrorHandler)
        {
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));

            _messageHandler = validationErrorHandler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OrigLearnStartDate_04Rule" /> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        public OrigLearnStartDate_04Rule(IValidationErrorHandler validationErrorHandler)
        {
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));

            _messageHandler = validationErrorHandler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AFinType_13Rule"/> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        public AFinType_13Rule(IValidationErrorHandler validationErrorHandler)
        {
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));

            _messageHandler = validationErrorHandler;
        }
示例#30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WithdrawReason_03Rule"/> class.
        /// </summary>
        /// <param name="validationErrorHandler">The validation error handler.</param>
        public WithdrawReason_03Rule(IValidationErrorHandler validationErrorHandler)
        {
            It.IsNull(validationErrorHandler)
            .AsGuard <ArgumentNullException>(nameof(validationErrorHandler));

            _messageHandler = validationErrorHandler;
        }