public async Task ShouldValidate()
        {
            var viewModel   = new ApprenticeshipViewModel();
            var updateModel = new CreateApprenticeshipUpdateViewModel();

            _mockMapper
            .Setup(m => m.MapApprenticeship(It.IsAny <ApprenticeshipViewModel>()))
            .ReturnsAsync(new Apprenticeship {
                ReservationId = Guid.NewGuid(), StartDate = DateTime.Today
            });

            _mockMediator
            .Setup(m => m.Send(It.IsAny <GetOverlappingApprenticeshipsQueryRequest>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetOverlappingApprenticeshipsQueryResponse {
                Overlaps = new List <ApprenticeshipOverlapValidationResult>()
            });

            _mockMediator
            .Setup(m => m.Send(It.IsAny <GetReservationValidationRequest>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetReservationValidationResponse {
                Data = new ReservationValidationResult(new ReservationValidationError[0])
            });

            await _orchestrator.ValidateEditApprenticeship(viewModel, updateModel);

            _mockMediator.Verify(m => m.Send(It.IsAny <GetOverlappingApprenticeshipsQueryRequest>(), It.IsAny <CancellationToken>()), Times.Once, failMessage: "Should call");
            _mockMediator.Verify(m => m.Send(It.IsAny <GetReservationValidationRequest>(), It.IsAny <CancellationToken>()), Times.Once, failMessage: "Should call");
            _mockValidator.Verify(m => m.MapOverlappingErrors(It.IsAny <GetOverlappingApprenticeshipsQueryResponse>()), Times.Once, failMessage: "Should verify overlapping apprenticeship");
            _mockValidator.Verify(m => m.ValidateToDictionary(It.IsAny <ApprenticeshipViewModel>()), Times.Once, failMessage: "Should validate apprenticeship");
            _mockValidator.Verify(m => m.ValidateAcademicYear(It.IsAny <CreateApprenticeshipUpdateViewModel>()), Times.Once, failMessage: "Should validate academic year");
        }
        public async Task <ActionResult> ConfirmChanges(long providerId, ApprenticeshipViewModel model)
        {
            var updateViewModel = await _orchestrator.GetConfirmChangesModel(providerId, model.HashedApprenticeshipId, model);

            var validationErrors = await _orchestrator.ValidateEditApprenticeship(model, updateViewModel);

            foreach (var error in validationErrors)
            {
                if (ModelState.ContainsKey(error.Key))
                {
                    continue;
                }
                ModelState.AddModelError(error.Key, error.Value);
            }

            if (!ModelState.IsValid)
            {
                return(await RedisplayEditApprenticeshipView(model));
            }


            if (!AnyChanges(updateViewModel))
            {
                ModelState.AddModelError("NoChangesRequested", "No changes made");
                return(await RedisplayEditApprenticeshipView(model));
            }

            ModelState.Clear();
            return(View(updateViewModel));
        }