Exemplo n.º 1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (string.IsNullOrEmpty(_adwRepository.GetDescription(
                                         DataConstants.AdwListCodeForProjectTypes, ProjectType)))
            {
                yield return(new ValidationResult("Project Type is not valid", new[] { "ProjectType" }));
            }

            if (NoneOfTheResourcesHaveBeenTicked())
            {
                yield return(new ValidationResult("At least one resource must be selected", new[] { "Resource_NO" }));
            }
        }
Exemplo n.º 2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (!string.IsNullOrEmpty(AssessmentCode))
            {
                if (string.IsNullOrEmpty(_adwRepository.GetDescription(
                                             DataConstants.AdwListCodeForAssessmentCodes, AssessmentCode, false))) // check regardless of the adw end date status and must be exists
                {
                    yield return(new ValidationResult("Assessment outcome is not valid", new[] { "AssessmentCode" }));
                }
            }

            if (!string.IsNullOrEmpty(RecoveryReason))
            {
                if (string.IsNullOrEmpty(_adwRepository.GetDescription(
                                             DataConstants.AdwListCodeForRecoveryReasonCodes, RecoveryReason, false)))  // check regardless of the adw end date status and must be exists
                {
                    yield return(new ValidationResult("Recovery reason is not valid", new[] { "RecoveryReason" }));
                }
            }

            if (!string.IsNullOrEmpty(AssessmentAction))
            {
                if (string.IsNullOrEmpty(_adwRepository.GetDescription(
                                             DataConstants.AdwListCodeForAssessmentActionCodes, AssessmentAction, false))) // check regardless of the adw end date status and must be exists
                {
                    yield return(new ValidationResult("Assessment action is not valid", new[] { "AssessmentAction" }));
                }
            }

            if (!string.IsNullOrEmpty(OutcomeCode))
            {
                if (string.IsNullOrEmpty(_adwRepository.GetDescription(
                                             DataConstants.AdwListCodeForOutcomeCodes, OutcomeCode, false))) // check regardless of the adw end date status and must be exists
                {
                    yield return(new ValidationResult("Final outcome is not valid", new[] { "OutcomeCode" }));
                }
            }

            if (ClaimRecoveryAmount > ClaimAmount)
            {
                yield return(new ValidationResult("Recovery amount cannot be greater than the amount of the claim", new[] { "ClaimRecoveryAmount" }));
            }

            if (ClaimRecoveryAmount < 0)
            {
                yield return(new ValidationResult("Recovery amount cannot be negative", new[] { "ClaimRecoveryAmount" }));
            }
        }
Exemplo n.º 3
0
        public bool CheckAdw(PatColumn column, string value, ref string optionalMessage)
        {
            var isValid = true;

            if (string.IsNullOrEmpty(_adwRepository.GetDescription(column.ListCode, value)))
            {
                isValid         = false;
                optionalMessage = string.Format("{0} is not a valid {1}", value, column.ColumnName);
            }
            return(isValid);
        }
Exemplo n.º 4
0
        public string GetProjectContractDescription()
        {
            var desc = string.Empty;

            if (!string.IsNullOrEmpty(ContractType))
            {
                desc = _adwRepository.GetDescription(DataConstants.AdwListCodeForProjectContracts, ContractType);
                if (string.IsNullOrEmpty(desc))
                {
                    desc = string.Format("Contract Type :{0} - not found in ADW", ContractType);
                }
            }
            return(desc);
        }
Exemplo n.º 5
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var result = new List <ValidationResult>();

            if (string.IsNullOrWhiteSpace(_adwRepository.GetDescription(DataConstants.AdwListCodeForBulletinTypes, BulletinType)))
            {
                var error = string.Format("Bulletin Type: {0} not found in ADW", BulletinType);
                result.Add(new ValidationResult(error, new[] { "BulletinType" }));
            }

            var startDateIsEmpty = false;

            if ((StartDate == new DateTime(1, 1, 1)))
            {
                startDateIsEmpty = true;
                result.Add(new ValidationResult("Start Date is mandatory and cannot be blank", new[] { "StartDate" }));
            }

            var endDateIsEmpty = false;

            if ((EndDate == new DateTime(1, 1, 1)))
            {
                endDateIsEmpty = true;
                result.Add(new ValidationResult("End Date is mandatory and cannot be blank", new[] { "EndDate" }));
            }

            if (!startDateIsEmpty)
            {
                if (BulletinId < 1 && !(StartDate >= DateTime.Today))
                {
                    // DR01039364 = Start Date must be equal to or greater than the current date.
                    result.Add(new ValidationResult("Start Date must be equal to or greater than the current date", new[] { "StartDate" }));
                }

                if (!endDateIsEmpty)
                {
                    if (!(StartDate < EndDate))
                    {
                        // DR01039363 || DR01039376 =  Start Date must be less than the End Date.
                        result.Add(new ValidationResult("Start Date must be less than the End Date", new[] { "StartDate" }));
                    }
                }
            }

            return(result);
        }