예제 #1
0
 public DebtDetailResponse ToDebtDetail(DynamicsGatewayOptions options)
 {
     return(new DebtDetailResponse
     {
         Id = Id,
         Amount = decimal.Parse(Amount),
         Reference = CreditorExternalReference,
         DebtTypeName = Type,
         NINO = NationalInsuranceNumber,
         CreatedOn = CreatedOn.ToDateTimeOffset(),
         ModifiedOn = ModifiedOn.ToDateTimeOffset(),
         Status = options.DebtStatus[StatusId.ToString()],
         SoldToCreditorName = ProposedCreditor?.Name,
         SoldToCreditorId = ProposedCreditor?.Id,
         PreviouslySold = PreviouslySold,
         CreditorName = Creditor.Name,
         CreditorId = Creditor.Id,
         StartsOn = CommencementDate?.ToDateTimeOffset(),
         EndsOn = ExpiryDate?.ToDateTimeOffset(),
         RemovedOn = RemovalDate?.ToDateTimeOffset(),
         DebtTypeId = TypeId,
         DebtEligibilityReview = DebtEligibilityReview != null
             ? DebtEligibilityReview.ToDebtEligibilityReview(options)
             : null,
         DebtRemovalReason = DebtRemovalReasonId.HasValue ?
                             options.DebtRemovalReason.First(r => r.Value == DebtRemovalReasonId.ToString()).Key :
                             (DebtRemovalReason?)null
     });
 }
예제 #2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Command != KeyDatesStatusEnum.ArchiveReference && !NewDate.IsCompleted)
            {
                yield return(new ValidationResult("Please enter a valid date", new[] { "NewDate" }));
            }

            if (Command == KeyDatesStatusEnum.NotificationReceived)
            {
                if (NewDate.AsDateTime() > SystemTime.UtcNow)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.ReceivedInFuture, new[] { "NewDate" }));
                }
            }

            if (Command == KeyDatesStatusEnum.AssessmentCommenced)
            {
                if (string.IsNullOrWhiteSpace(NameOfOfficer))
                {
                    yield return(new ValidationResult(DateInputViewModelResources.NameOfOfficer, new[] { "NameOfOfficer" }));
                }
                else if (NameOfOfficer.Count() > 256)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.NameOfOfficerLength, new[] { "NameOfOfficer" }));
                }

                if (NewDate.AsDateTime() > SystemTime.UtcNow)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.CommencedInFuture, new[] { "NewDate" }));
                }

                if (NotificationReceivedDate == null || PaymentReceivedDate == null)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.CommencedOtherDatesRequired, new[] { "NewDate" }));
                }

                if ((NotificationReceivedDate != null && NewDate.AsDateTime() < NotificationReceivedDate.AsDateTime()) ||
                    (PaymentReceivedDate != null && NewDate.AsDateTime() < PaymentReceivedDate))
                {
                    yield return(new ValidationResult(DateInputViewModelResources.CommencedNotBefore, new[] { "NewDate" }));
                }
            }

            if (Command == KeyDatesStatusEnum.NotificationComplete)
            {
                if (NewDate.AsDateTime() > SystemTime.UtcNow)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.CompleteInFuture, new[] { "NewDate" }));
                }

                if (NotificationReceivedDate == null || PaymentReceivedDate == null || CommencementDate == null)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.CompleteOtherDatesRequired, new[] { "NewDate" }));
                }

                if ((NotificationReceivedDate != null && NewDate.AsDateTime() < NotificationReceivedDate.AsDateTime()) ||
                    (PaymentReceivedDate != null && NewDate.AsDateTime() < PaymentReceivedDate))
                {
                    yield return(new ValidationResult(DateInputViewModelResources.CompleteNotBefore, new[] { "NewDate" }));
                }
            }

            if (Command == KeyDatesStatusEnum.NotificationTransmitted)
            {
                if (NewDate.AsDateTime() > SystemTime.UtcNow)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.TransmittedInFuture, new[] { "NewDate" }));
                }

                if (NotificationReceivedDate == null || PaymentReceivedDate == null || CommencementDate == null ||
                    NotificationCompleteDate == null)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.TransmittedOtherDatesRequired, new[] { "NewDate" }));
                }

                if ((NotificationReceivedDate != null && NewDate.AsDateTime() < NotificationReceivedDate.AsDateTime()) ||
                    (PaymentReceivedDate != null && NewDate.AsDateTime() < PaymentReceivedDate) ||
                    (CommencementDate != null && NewDate.AsDateTime() < CommencementDate.AsDateTime()) ||
                    (NotificationCompleteDate != null && NewDate.AsDateTime() < NotificationCompleteDate.AsDateTime()))
                {
                    yield return(new ValidationResult(DateInputViewModelResources.TransmittedNotBefore, new[] { "NewDate" }));
                }
            }

            if (Command == KeyDatesStatusEnum.NotificationAcknowledged)
            {
                if (NewDate.AsDateTime() > SystemTime.UtcNow)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.AcknowledgedInFuture, new[] { "NewDate" }));
                }

                if (NotificationReceivedDate == null || PaymentReceivedDate == null || CommencementDate == null ||
                    NotificationCompleteDate == null || NotificationTransmittedDate == null)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.AcknowledgedOtherDatesRequired, new[] { "NewDate" }));
                }

                if ((NotificationReceivedDate != null && NewDate.AsDateTime() < NotificationReceivedDate.AsDateTime()) ||
                    (PaymentReceivedDate != null && NewDate.AsDateTime() < PaymentReceivedDate) ||
                    (CommencementDate != null && NewDate.AsDateTime() < CommencementDate.AsDateTime()) ||
                    (NotificationCompleteDate != null && NewDate.AsDateTime() < NotificationCompleteDate.AsDateTime()) ||
                    (NotificationTransmittedDate != null && NewDate.AsDateTime() < NotificationTransmittedDate.AsDateTime()))
                {
                    yield return(new ValidationResult(DateInputViewModelResources.AcknowledgedNotBefore, new[] { "NewDate" }));
                }
            }

            if (Command == KeyDatesStatusEnum.FileClosed)
            {
                if (NewDate.AsDateTime() > SystemTime.UtcNow)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.FileClosedInFuture, new[] { "NewDate" }));
                }

                if (NotificationReceivedDate == null)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.CompleteOtherDatesRequired, new[] { "NewDate" }));
                }

                if (NotificationReceivedDate != null && NewDate.AsDateTime() < NotificationReceivedDate.AsDateTime())
                {
                    yield return(new ValidationResult(DateInputViewModelResources.FileClosedNotBefore, new[] { "NewDate" }));
                }
            }

            if (Command == KeyDatesStatusEnum.ArchiveReference)
            {
                if (string.IsNullOrWhiteSpace(ArchiveReference))
                {
                    yield return(new ValidationResult(DateInputViewModelResources.ArchiveReferenceRequired, new[] { "ArchiveReference" }));
                }
                else if (ArchiveReference.Length > 100)
                {
                    yield return(new ValidationResult(DateInputViewModelResources.ArchiveReferenceLength, new[] { "ArchiveReference" }));
                }
            }
        }