Beispiel #1
0
        protected override IEnumerable <ValidationResult> Validate()
        {
            var validationResults = base.Validate();

            if (AgentInfo != null)
            {
                validationResults = validationResults.Concat(AgentInfo.Validate());
            }

            foreach (var i in Items)
            {
                if (i is PositionDocumentParams p)
                {
                    if (p.AgentInfo != null)
                    {
                        var positionAgentValidationErrors = p.AgentInfo.Validate();

                        if (positionAgentValidationErrors.Any())
                        {
                            validationResults = new List <ValidationResult>(validationResults)
                            {
                                new ValidationResult(
                                    string.Format(
                                        ErrorStrings.ResourceManager.GetString("AgentInPositionValidationError"),
                                        p.Name) +
                                    positionAgentValidationErrors.Aggregate(string.Empty,
                                                                            (current, c) => current + "\n\t" + c.ErrorMessage))
                            };
                        }
                    }
                }
            }

            return(validationResults);
        }
Beispiel #2
0
        protected override IEnumerable <ValidationResult> Validate()
        {
            var validationResults = base.Validate();

            if (CorrectionType == CorrectionReceiptCorrectionType.Instruction &&
                CorrectionBaseNumber.IsNullOrEmptyOrWhiteSpace())
            {
                validationResults = new List <ValidationResult>(validationResults)
                {
                    new ValidationResult(string.Format(
                                             ErrorStrings.ResourceManager.GetString("RequiredError"),
                                             this.GetType().GetProperty(nameof(CorrectionBaseNumber)).GetDisplayName()))
                };
            }

            if (AgentInfo != null)
            {
                validationResults = validationResults.Concat(AgentInfo.Validate());
            }

            foreach (var i in Items)
            {
                if (i is PositionDocumentParams p)
                {
                    if (p.AgentInfo != null)
                    {
                        var positionAgentValidationErrors = p.AgentInfo.Validate();

                        if (positionAgentValidationErrors.Any())
                        {
                            validationResults = new List <ValidationResult>(validationResults)
                            {
                                new ValidationResult(
                                    string.Format(
                                        ErrorStrings.ResourceManager.GetString("AgentInPositionValidationError"),
                                        p.Name) +
                                    positionAgentValidationErrors.Aggregate(string.Empty,
                                                                            (current, c) => current + "\n\t" + c.ErrorMessage))
                            };
                        }
                    }
                }
            }

            return(validationResults);
        }