Example #1
0
        public async Task <AddEditApprenticeshipsViewModel> UpdateAddApprenticeship(AddEditApprenticeshipsViewModel viewModel)
        {
            var course =
                viewModel.Course.Id != null
                    ? await _apprenticeshipCourseService.GetApprenticeshipCourse(viewModel.Course.Id)
                    : null;

            var totalCostAsString = (decimal.TryParse(viewModel.TotalCostAsString, out decimal result))
                ? result.FormatValue()
                : viewModel.TotalCostAsString = string.Empty;

            viewModel.Course            = course;
            viewModel.TotalCostAsString = totalCostAsString;

            return(viewModel);
        }
        public async Task <AddEditApprenticeshipsViewModel> EditApprenticeshipModel(string hashedAccountId,
                                                                                    string apprenticeshipsId, string estimationName)
        {
            var accountId   = _hashingService.DecodeValue(hashedAccountId);
            var estimations = await _estimationRepository.Get(accountId);

            var model  = estimations.FindVirtualApprenticeship(apprenticeshipsId);
            var course = await _apprenticeshipCourseService.GetApprenticeshipCourse(model.CourseId);

            return(new AddEditApprenticeshipsViewModel
            {
                Course = course,
                ApprenticeshipsId = apprenticeshipsId,
                EstimationName = estimationName,

                NumberOfApprentices = model.ApprenticesCount,
                TotalInstallments = model.TotalInstallments,
                TotalCostAsString = model.TotalCost.FormatValue(),
                StartDateMonth = model.StartDate.Month,
                StartDateYear = model.StartDate.Year,
                HashedAccountId = hashedAccountId
            });
        }
Example #3
0
        internal async Task <ApprenticeshipMessage> Map(ApiApprenticeship apprenticeship)
        {
            if (apprenticeship == null)
            {
                return(new ApprenticeshipMessage());
            }

            var duration = 0;

            if (apprenticeship.EndDate.HasValue && apprenticeship.StartDate.HasValue)
            {
                duration = (apprenticeship.EndDate.Value.Year - apprenticeship.StartDate.Value.Year) * 12 +
                           apprenticeship.EndDate.Value.Month - apprenticeship.EndDate.Value.Month;
            }

            var training = await _apprenticeshipCourseDataService.GetApprenticeshipCourse(apprenticeship.TrainingCode);

            return(new ApprenticeshipMessage
            {
                EmployerAccountId = apprenticeship.EmployerAccountId,
                SendingEmployerAccountId = apprenticeship.TransferSenderId,
                LearnerId = long.TryParse(apprenticeship.ULN, out var result) ? result : 0,
                ProviderId = apprenticeship.ProviderId,
                ProviderName = apprenticeship.ProviderName,
                ApprenticeshipId = apprenticeship.Id,
                ApprenticeName = $"{apprenticeship.FirstName} {apprenticeship.LastName}",
                CourseName = apprenticeship.TrainingName,
                CourseLevel = training?.Level ?? 0,
                StartDate = apprenticeship.StartDate.Value,
                PlannedEndDate = apprenticeship.EndDate.Value,
                ActualEndDate = null,
                CompletionAmount = apprenticeship.Cost.Value * 0.2M,
                MonthlyInstallment = (apprenticeship.Cost.Value * 0.8M) / duration,
                NumberOfInstallments = duration,
                FundingSource = apprenticeship.TransferSenderId == null ? FundingSource.Levy : FundingSource.Transfer
            });