protected override async Task HandleCore(UpdateApprenticeshipStopDateCommand command)
        {
            var validationResult = _validator.Validate(command);

            if (!validationResult.IsValid())
            {
                throw new InvalidRequestException(validationResult.ValidationDictionary);
            }

            var stopDate = new ApprenticeshipStopDate
            {
                UserId            = command.UserId,
                LastUpdatedByInfo = new LastUpdateInfo {
                    EmailAddress = command.UserEmailAddress, Name = command.UserDisplayName
                },
                NewStopDate = command.NewStopDate
            };

            var apprenticeship = await
                                 _commitmentsApi.GetEmployerApprenticeship(command.EmployerAccountId, command.ApprenticeshipId);

            ValidateNewStopDate(command, apprenticeship);

            await _commitmentsApi.PutApprenticeshipStopDate(command.EmployerAccountId, command.CommitmentId, command.ApprenticeshipId, stopDate);

            await _providerEmailNotificationService.SendProviderApprenticeshipStopEditNotification(apprenticeship,
                                                                                                   command.NewStopDate);
        }
コード例 #2
0
        public async Task ThenAppropriateCommandIsSentToMediator()
        {
            //Arrange
            var stopDate = new ApprenticeshipStopDate
            {
                NewStopDate       = DateTime.Today,
                LastUpdatedByInfo = new LastUpdateInfo(),
                UserId            = "TEST"
            };

            //Act
            await Orchestrator.PutApprenticeshipStopDate(1, 1, 1, stopDate);

            //Assert
            MockMediator.Verify(x => x.SendAsync(It.IsAny <UpdateApprenticeshipStopDateCommand>()), Times.Once);
        }
        public async Task PutApprenticeshipStopDate(long accountId, long commitmentId, long apprenticeshipId, ApprenticeshipStopDate stopDate)
        {
            var url  = $"{_configuration.BaseUrl}api/employer/{accountId}/commitments/{commitmentId}/apprenticeships/{apprenticeshipId}/stopdate";
            var data = JsonConvert.SerializeObject(stopDate);

            await PutAsync(url, data);
        }
コード例 #4
0
        public async Task <IHttpActionResult> PutApprenticeshipStopDate(long accountId, long commitmentId, long apprenticeshipId, [FromBody] ApprenticeshipStopDate stopDate)
        {
            await _employerOrchestrator.PutApprenticeshipStopDate(accountId, commitmentId, apprenticeshipId, stopDate);

            return(StatusCode(HttpStatusCode.NoContent));
        }