public static async Task <Incentive> Create(
            IncentiveApplicationApprenticeshipDto incentiveApplication,
            IIncentivePaymentProfilesService incentivePaymentProfilesService)
        {
            var paymentProfiles = await incentivePaymentProfilesService.Get();

            return(Create(incentiveApplication.Phase, incentiveApplication.DateOfBirth, incentiveApplication.PlannedStartDate, paymentProfiles, new List <BreakInLearning>()));
        }
Example #2
0
 private ApplicationApprenticeshipModel MapFromApplicationApprenticeDto(IncentiveApplicationApprenticeshipDto apprentice)
 {
     return(new ApplicationApprenticeshipModel
     {
         ApprenticeshipId = _hashingService.HashValue(apprentice.ApprenticeshipId),
         CourseName = apprentice.CourseName,
         FirstName = apprentice.FirstName,
         LastName = apprentice.LastName,
         ExpectedAmount = apprentice.TotalIncentiveAmount,
         StartDate = apprentice.PlannedStartDate,
         Uln = apprentice.Uln
     });
 }
        public async Task Then_apprenticeships_are_ordered()
        {
            // Arrange
            var account     = _fixture.Create <Models.Account>();
            var application = _fixture.Build <Models.IncentiveApplication>()
                              .With(x => x.AccountId, account.Id)
                              .With(x => x.AccountLegalEntityId, account.AccountLegalEntityId)
                              .Create();

            application.Apprenticeships = new List <Models.IncentiveApplicationApprenticeship>()
            {
                _fixture.Build <Models.IncentiveApplicationApprenticeship>().With(a => a.FirstName, "ZFirst").With(a => a.LastName, "ALast").With(a => a.ULN, 9).Create(),
                _fixture.Build <Models.IncentiveApplicationApprenticeship>().With(a => a.FirstName, "AFirst").With(a => a.LastName, "ALast").With(a => a.ULN, 1).Create(),
                _fixture.Build <Models.IncentiveApplicationApprenticeship>().With(a => a.FirstName, "AFirst").With(a => a.LastName, "ALast").With(a => a.ULN, 9).Create(),
                _fixture.Build <Models.IncentiveApplicationApprenticeship>().With(a => a.FirstName, "AFirst").With(a => a.LastName, "ZLast").With(a => a.ULN, 9).Create()
            };

            _context.Accounts.Add(account);
            _context.Applications.AddRange(application);
            _context.SaveChanges();

            // Act
            var actual = (await _sut.GetList(x => x.AccountId == account.Id)).Single();

            //Assert
            actual.Apprenticeships.Count().Should().Be(4);

            IncentiveApplicationApprenticeshipDto previous = null;

            foreach (var apprenticeship in actual.Apprenticeships)
            {
                if (previous != null)
                {
                    apprenticeship.FirstName.CompareTo(previous.FirstName).Should().BeGreaterOrEqualTo(0);
                    if (apprenticeship.FirstName.CompareTo(previous.FirstName) == 0)
                    {
                        apprenticeship.LastName.CompareTo(previous.LastName).Should().BeGreaterOrEqualTo(0);
                        if (apprenticeship.LastName.CompareTo(previous.LastName) == 0)
                        {
                            previous.Uln.Should().BeLessOrEqualTo(apprenticeship.Uln);
                        }
                    }
                }

                previous = apprenticeship;
            }
        }
Example #4
0
        private static void ValidateApprenticeship(ValidationResult result, IncentiveApplicationApprenticeshipDto apprenticeship)
        {
            if (apprenticeship.ApprenticeshipId == default)
            {
                result.AddError("Apprenticeship.ApprenticeshipId", "Is not set");
            }

            if (apprenticeship.DateOfBirth == default)
            {
                result.AddError("Apprenticeship.DateOfBirth", "Is not set");
            }

            if (apprenticeship.PlannedStartDate == default)
            {
                result.AddError("Apprenticeship.PlannedStartDate", "Is not set");
            }

            if (apprenticeship.ULN == default)
            {
                result.AddError("Apprenticeship.ULN", "Is not set");
            }

            if (string.IsNullOrEmpty(apprenticeship.FirstName))
            {
                result.AddError("Apprenticeship.FirstName", "Is not set");
            }

            if (string.IsNullOrEmpty(apprenticeship.LastName))
            {
                result.AddError("Apprenticeship.LastName", "Is not set");
            }

            if (apprenticeship.UKPRN == default)
            {
                result.AddError("Apprenticeship.UKPRN", "Is not set");
            }
        }