public async Task PublishEvent(Commitment commitment, Apprenticeship apprenticeship, string @event, DateTime?effectiveFrom = null, DateTime?effectiveTo = null) { var apprenticeshipEvent = CreateEvent(commitment, apprenticeship, @event, (PaymentStatus)apprenticeship.PaymentStatus, effectiveFrom, effectiveTo); _logger.Info($"Create apprenticeship event: {apprenticeshipEvent.Event}", commitmentId: commitment.Id, apprenticeshipId: apprenticeship.Id); await _eventsApi.CreateApprenticeshipEvent(apprenticeshipEvent); }
public virtual async Task <List <ProviderUser> > GetUsersAsync(long ukprn) { var url = string.Format(_config.IdamsListUsersUrl, _config.DasUserRoleId, ukprn); _logger.Info($"Getting 'DAS' emails for provider {ukprn}"); var result = await GetString(url, _config.ClientToken); return(ParseIdamsResult(result, ukprn)); }
private void LogMessage(UpdateCommitmentAgreementCommand command) { string messageTemplate = $"{command.Caller.CallerType}: {command.Caller.Id} has called UpdateCommitmentAgreement for commitment {command.CommitmentId} with agreement status: {command.LatestAction}"; if (command.Caller.CallerType == CallerType.Employer) { _logger.Info(messageTemplate, accountId: command.Caller.Id, commitmentId: command.CommitmentId); } else { _logger.Info(messageTemplate, providerId: command.Caller.Id, commitmentId: command.CommitmentId); } }
private void LogMessage(DeleteApprenticeshipCommand command) { string messageTemplate = $"{command.Caller.CallerType}: {command.Caller.Id} has called DeleteApprenticeshipCommand"; if (command.Caller.CallerType == CallerType.Employer) { _logger.Info(messageTemplate, accountId: command.Caller.Id, apprenticeshipId: command.ApprenticeshipId); } else { _logger.Info(messageTemplate, providerId: command.Caller.Id, apprenticeshipId: command.ApprenticeshipId); } }
private async Task CheckOverlappingApprenticeships(CreateApprenticeshipUpdateCommand command, Apprenticeship originalApprenticeship) { var coalesce = new Func <string, string, string>((s, s1) => string.IsNullOrWhiteSpace(s) ? s1 : s); var overlapResult = await _mediator.SendAsync(new GetOverlappingApprenticeshipsRequest { OverlappingApprenticeshipRequests = new List <ApprenticeshipOverlapValidationRequest> { new ApprenticeshipOverlapValidationRequest { ApprenticeshipId = originalApprenticeship.Id, Uln = coalesce(command.ApprenticeshipUpdate.ULN, originalApprenticeship.ULN), StartDate = command.ApprenticeshipUpdate.StartDate ?? originalApprenticeship.StartDate.Value, EndDate = command.ApprenticeshipUpdate.EndDate ?? originalApprenticeship.EndDate.Value } } }); if (overlapResult.Data.Any()) { foreach (var overlap in overlapResult.Data) { _logger.Info($"ApprenticeshipUpdate overlaps with apprenticeship {overlap.Id}"); } throw new ValidationException("Unable to create ApprenticeshipUpdate due to overlapping apprenticeship"); } }
public async Task <GetActiveApprenticeshipsByUlnResponse> Handle(GetActiveApprenticeshipsByUlnRequest query) { var validationResult = _validator.Validate(query); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } var result = new GetActiveApprenticeshipsByUlnResponse(); if (string.IsNullOrWhiteSpace(query.Uln)) { return(result); } var apprenticeships = await _apprenticeshipRepository.GetActiveApprenticeshipsByUlns(new List <string> { query.Uln }); foreach (var apprenticeship in apprenticeships) { _logger.Info($"Found active apprenticeships for Uln: {query.Uln} " + $"Apprenticeship Id: {apprenticeship.Id} {apprenticeship.StartDate:MMM yyyy} - {apprenticeship.EndDate:MMM yyyy}"); } result.Data = apprenticeships; return(result); }
public async Task <IEnumerable <Email> > GetEmails() { var alertSummaries = await _apprenticeshipRepository.GetProviderApprenticeshipAlertSummary(); _logger.Info($"Found {alertSummaries.Count} provider summary records."); var distinctProviderIds = alertSummaries .Select(m => m.ProviderId) .Distinct() .ToList(); var providerTasks = distinctProviderIds .Select(GetProvider) .ToList(); await Task.WhenAll(providerTasks); var providers = providerTasks.Select(x => x.Result).ToList(); var emails = providers .SelectMany(p => p .Where(m => m.ReceiveNotifications) .Select(m => MapToEmail(m, alertSummaries))); return(emails); }
private async Task <ReservationValidationResult> CheckReservationIfRequired(ReservationValidationServiceRequest request) { if (request.ReservationId == null) { _logger.Info($"Commitment:{request.CommitmentId} Apprenticeship: {request.ApprenticeshipId} Reservation-id:null - no reservation validation required"); return(NoValidationRequiredResponse); } if (request.StartDate == null) { throw new ValidationException( $"Unable to validate the reservation because the start date is absent"); } var validationReservationMessage = new ReservationValidationMessage { ReservationId = request.ReservationId.Value, CourseCode = request.TrainingCode, StartDate = request.StartDate.Value }; var validationResult = await _reservationsApiClient.ValidateReservation(validationReservationMessage, CancellationToken.None); return(validationResult); }
public async Task <IEnumerable <ApprenticeshipOverlapValidationResult> > ValidateOverlappingApprenticeships( IEnumerable <ApprenticeshipOverlapValidationRequest> apprenticeshipOverlapValidationRequests) { var requests = apprenticeshipOverlapValidationRequests.ToList(); _logger.Trace($"Validating {requests.Count} overlapping validation requests"); var command = new Application.Queries.GetOverlappingApprenticeships.GetOverlappingApprenticeshipsRequest { OverlappingApprenticeshipRequests = requests.Select(Map).ToList() }; var response = await _mediator.SendAsync(command); var result = new List <ApprenticeshipOverlapValidationResult>(); var requestGroups = response.Data.GroupBy(x => x.RequestApprenticeshipId).ToList(); foreach (var group in requestGroups) { result.Add(new ApprenticeshipOverlapValidationResult { Self = requests.Single(x => x.ApprenticeshipId == group.Key), OverlappingApprenticeships = response.Data .Select(MapFrom) .Where(x => x.RequestApprenticeshipId == group.Key) }); } _logger.Info($"Validated {requests.Count} overlapping validation requests"); return(result); }
protected override async Task HandleCore(UpdateApprenticeshipStopDateCommand command) { _logger.Info($"Employer: {command.AccountId} has called StopApprenticeshipCommand", command.AccountId, apprenticeshipId: command.ApprenticeshipId, caller: command.Caller); var validationResult = _validator.Validate(command); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } var apprenticeship = await _apprenticeshipRepository.GetApprenticeship(command.ApprenticeshipId); var commitment = await _commitmentRepository.GetCommitmentById(apprenticeship.CommitmentId); CheckAuthorization(command, commitment); ValidateChangeDateForStop(command.StopDate, apprenticeship); await SaveChange(command, commitment, apprenticeship); if (command.StopDate == apprenticeship.StartDate) { await ResolveDataLocksForApprenticeship(apprenticeship.Id); } await PublishEvent(command, commitment, apprenticeship); }
protected override async Task HandleCore(PauseApprenticeshipCommand command) { _logger.Info($"Employer: {command.AccountId} has called PauseApprenticeshipCommand", command.AccountId, apprenticeshipId: command.ApprenticeshipId, caller: command.Caller); var validationResult = _validator.Validate(command); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } var apprenticeship = await _apprenticeshipRepository.GetApprenticeship(command.ApprenticeshipId); var commitment = await _commitmentRepository.GetCommitmentById(apprenticeship.CommitmentId); CheckAuthorization(command, commitment); ValidateChangeDate(command.DateOfChange); await SaveChange(command, commitment, apprenticeship); await CreateEvent(command, apprenticeship, commitment); }
public async Task <long> Handle(CreateCommitmentCommand message) { _logger.Info($"Employer: {message.Commitment.EmployerAccountId} has called CreateCommitmentCommand", accountId: message.Commitment.EmployerAccountId); var validationResult = _validator.Validate(message); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } var newCommitment = message.Commitment; newCommitment.LastAction = LastAction.None; newCommitment.Id = await _commitmentRepository.Create(newCommitment); await _commitmentRepository.UpdateCommitmentReference(newCommitment.Id, _hashingService.HashValue(newCommitment.Id)); await CreateMessageIfNeeded(newCommitment.Id, message); await CreateHistory(newCommitment, message.Caller.CallerType, message.UserId, message.Commitment.LastUpdatedByEmployerName); return(newCommitment.Id); }
public async Task <IEnumerable <ApprenticeshipUpdate> > GetExpiredApprenticeshipUpdates(DateTime currentAcademicYearStartDate) { _logger.Info($"Getting all expired apprenticeship update"); var parameters = new DynamicParameters(); parameters.Add("@status", ApprenticeshipUpdateStatus.Pending, DbType.Int16); parameters.Add("@date", currentAcademicYearStartDate, DbType.DateTime); return(await WithTransaction( async (connection, trans) => await connection.QueryAsync <ApprenticeshipUpdate>( sql: $"[dbo].[GetApprenticeshipUpdatesByDateAndStatus]", param: parameters, commandType: CommandType.StoredProcedure, transaction: trans))); }
public async Task PublishApprenticeshipCreated(IApprenticeshipEvent apprenticeshipEvent) { DateTime GetTransferApprovalOrAgreedOnDate() { if (apprenticeshipEvent.Commitment.TransferApprovalActionedOn.HasValue) { return(apprenticeshipEvent.Commitment.TransferApprovalActionedOn.Value); } return(apprenticeshipEvent.Apprenticeship.AgreedOn.Value); } var logMessage = $"Publish {typeof(ApprenticeshipCreatedEvent).Name} message. {GetLogMessage(apprenticeshipEvent)}"; try { DoPreChecks <ApprenticeshipCreatedEvent>(ApprenticePreChecks.HasStartAndEndDate, apprenticeshipEvent?.Apprenticeship); await _endpointInstance.Publish(new ApprenticeshipCreatedEvent { ApprenticeshipId = apprenticeshipEvent.Apprenticeship.Id, AgreedOn = apprenticeshipEvent.Apprenticeship.AgreedOn.Value, CreatedOn = GetTransferApprovalOrAgreedOnDate(), Uln = apprenticeshipEvent.Apprenticeship.ULN, ProviderId = apprenticeshipEvent.Apprenticeship.ProviderId, AccountId = apprenticeshipEvent.Apprenticeship.EmployerAccountId, AccountLegalEntityPublicHashedId = apprenticeshipEvent.Apprenticeship.AccountLegalEntityPublicHashedId, LegalEntityName = apprenticeshipEvent.Commitment.LegalEntityName, StartDate = apprenticeshipEvent.Apprenticeship.StartDate.Value, EndDate = apprenticeshipEvent.Apprenticeship.EndDate.Value, PriceEpisodes = GetPriceEpisodes(apprenticeshipEvent.Apprenticeship), TrainingType = (CommitmentsV2.Types.ProgrammeType)apprenticeshipEvent.Apprenticeship.TrainingType, TrainingCode = apprenticeshipEvent.Apprenticeship.TrainingCode, TransferSenderId = apprenticeshipEvent.Apprenticeship.TransferSenderId, ApprenticeshipEmployerTypeOnApproval = apprenticeshipEvent.Commitment.ApprenticeshipEmployerTypeOnApproval }); _logger.Info($"{logMessage} successful"); } catch (Exception e) { _logger.Error(e, $"{logMessage} failed"); throw; } }
protected override async Task HandleCore(ApproveDataLockTriageCommand command) { var validationResult = _validator.Validate(command); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } var datalocksForApprenticeship = await _dataLockRepository.GetDataLocks(command.ApprenticeshipId); var dataLocksToBeUpdated = datalocksForApprenticeship .Where(DataLockExtensions.UnHandled) .Where(m => m.TriageStatus == TriageStatus.Change); var apprenticeship = await _apprenticeshipRepository.GetApprenticeship(command.ApprenticeshipId); if (apprenticeship.HasHadDataLockSuccess) { dataLocksToBeUpdated = dataLocksToBeUpdated.Where(DataLockExtensions.IsPriceOnly); } var dataLockPasses = datalocksForApprenticeship.Where(x => x.Status == Status.Pass || x.PreviousResolvedPriceDataLocks()); if (!dataLocksToBeUpdated.Any()) { return; } var newPriceHistory = CreatePriceHistory(command, dataLocksToBeUpdated, dataLockPasses); await _apprenticeshipRepository.InsertPriceHistory(command.ApprenticeshipId, newPriceHistory); apprenticeship.PriceHistory = newPriceHistory.ToList(); if (!apprenticeship.HasHadDataLockSuccess) { var dataLockWithUpdatedTraining = dataLocksToBeUpdated.FirstOrDefault(m => m.IlrTrainingCourseCode != apprenticeship.TrainingCode); if (dataLockWithUpdatedTraining != null) { var training = await _apprenticeshipTrainingService.GetTrainingProgram(dataLockWithUpdatedTraining.IlrTrainingCourseCode); _logger.Info($"Updating course for apprenticeship {apprenticeship.Id} from training code {apprenticeship.TrainingCode} to {dataLockWithUpdatedTraining.IlrTrainingCourseCode}"); apprenticeship.TrainingCode = dataLockWithUpdatedTraining.IlrTrainingCourseCode; apprenticeship.TrainingName = training.Title; apprenticeship.TrainingType = dataLockWithUpdatedTraining.IlrTrainingType; await _apprenticeshipRepository.UpdateApprenticeship(apprenticeship, command.Caller); } } await _dataLockRepository.ResolveDataLock(dataLocksToBeUpdated.Select(m => m.DataLockEventId)); await PublishEvents(apprenticeship); }
internal async Task PublishApprenticeshipFinalApprovalEvents(Commitment commitment) { _logger.Info("Getting active apprenticeships for learners"); var existingApprenticeships = await GetActiveApprenticeshipsForLearners(commitment.Apprenticeships); Parallel.ForEach(commitment.Apprenticeships, apprenticeship => { var effectiveFromDate = DetermineApprovalEventEffectiveFromDate(apprenticeship.AgreementStatus, existingApprenticeships, apprenticeship.StartDate); _apprenticeshipEventsList.Add(commitment, apprenticeship, "APPRENTICESHIP-AGREEMENT-UPDATED", effectiveFromDate); }); _logger.Info($"Publishing {existingApprenticeships.Count()} apprenticeship agreement updates"); var apprenticeshipEventsListV2 = _apprenticeshipEventsList.Events?.ToList(); await Task.WhenAll( _apprenticeshipEventsPublisher.Publish(_apprenticeshipEventsList), PublishAllFinalApprovalEventsToV2(apprenticeshipEventsListV2)); }
public async Task Publish(IApprenticeshipEventsList events) { _logger.Info($"Publishing {events.Events.Count} events"); var apiEvents = events.Events.Select(x => CreateEvent(x.Commitment, x.Apprenticeship, x.Event, x.EffectiveFrom, x.EffectiveTo, x.PriceHistory)); var batches = SplitList(apiEvents.ToList(), _maxBatchSize).ToList(); if (batches.Count() > 1) { _logger.Info($"Splitting events into {batches.Count} batches of up to {_maxBatchSize}"); } foreach (var batch in batches) { _logger.Info($"Calling events api to bulk create {batch.Count} events"); await _eventsApi.BulkCreateApprenticeshipEvent(batch.ToList()); } events.Clear(); }
private async Task ValidateOverlaps(List <Apprenticeship> apprenticeships) { _logger.Info("Performing overlap validation for bulk upload"); var watch = Stopwatch.StartNew(); var overlapValidationRequest = new GetOverlappingApprenticeshipsRequest { OverlappingApprenticeshipRequests = new List <ApprenticeshipOverlapValidationRequest>() }; var i = 0; foreach (var apprenticeship in apprenticeships.Where(x => x.StartDate.HasValue && x.EndDate.HasValue && !string.IsNullOrEmpty(x.ULN))) { overlapValidationRequest.OverlappingApprenticeshipRequests.Add(new ApprenticeshipOverlapValidationRequest { ApprenticeshipId = i, //assign a row id, as this value will be zero for files Uln = apprenticeship.ULN, StartDate = apprenticeship.StartDate.Value, EndDate = apprenticeship.EndDate.Value }); i++; } _logger.Trace($"Building Overlap validation command took {watch.ElapsedMilliseconds} milliseconds"); watch = Stopwatch.StartNew(); if (overlapValidationRequest.OverlappingApprenticeshipRequests.Any()) { var overlapResponse = await _mediator.SendAsync(overlapValidationRequest); watch.Stop(); _logger.Trace($"Overlap validation took {watch.ElapsedMilliseconds} milliseconds"); if (overlapResponse.Data.Any()) { _logger.Info($"Found {overlapResponse.Data.Count} overlapping errors"); var errors = overlapResponse.Data.Select(overlap => new ValidationFailure(string.Empty, overlap.ValidationFailReason.ToString())).ToList(); throw new ValidationException(errors); } } }
public Task<Statistics> GetStatistics() { return WithConnection(async c => { _logger.Info("Getting statistics for consistency checks with RDS"); var results = await c.QueryAsync<Statistics>(sql: $"[dbo].[GetStatistics]", commandType: CommandType.StoredProcedure); return results.FirstOrDefault(); }); }
protected override async Task HandleCore(CreateRelationshipCommand message) { _logger.Info($"Employer: {message.Relationship.EmployerAccountId} has called CreateRelationshipCommand", accountId: message.Relationship.EmployerAccountId); var validationResult = _validator.Validate(message); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } await _commitmentRepository.CreateRelationship(message.Relationship); }
protected override async Task HandleCore(VerifyRelationshipCommand message) { _logger.Info($"Provider {message.ProviderId} has called VerifyRelationshipCommand for Employer {message.EmployerAccountId}, LegalEntity {message.LegalEntityId}"); var validationResult = _validator.Validate(message); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } await _commitmentRepository.VerifyRelationship(message.EmployerAccountId, message.ProviderId, message.LegalEntityId, message.Verified.Value); }
private async Task <IEnumerable <Apprenticeship> > MergeBulkCreatedReservationIdsOnToApprenticeships(IList <Apprenticeship> apprenticeships, Commitment commitment) { BulkCreateReservationsRequest BuildBulkCreateRequest() { return(new BulkCreateReservationsRequest { Count = (uint)apprenticeships.Count, TransferSenderId = commitment.TransferSenderId }); } BulkCreateReservationsResult bulkReservations; try { bulkReservations = await _reservationsApiClient.BulkCreateReservations( _encodingService.Decode(commitment.AccountLegalEntityPublicHashedId, EncodingType.PublicAccountLegalEntityId), BuildBulkCreateRequest(), CancellationToken.None); } catch (Exception e) { _logger.Error(e, "Failed calling BulkCreateReservations endpoint"); throw; } if (bulkReservations.ReservationIds.Length != apprenticeships.Count) { _logger.Info($"The number of bulk reservations did not match the number of apprentices"); throw new InvalidOperationException( $"The number of bulk reservations ({bulkReservations.ReservationIds.Length}) does not equal the number of apprenticeships ({apprenticeships.Count})"); } return(apprenticeships.Zip(bulkReservations.ReservationIds, (a, r) => { a.ReservationId = r; return a; })); }
private async Task SendCommandAndLog <TCommand>(TCommand @event, string message) where TCommand : class { var logMessage = $"Send {typeof(TCommand).Name} message. {message}"; try { await _endpointInstance.Send(@event); _logger.Info($"{logMessage} successful"); } catch (Exception e) { _logger.Error(e, $"{logMessage} failed"); throw; } }
public async Task <Types.DataLock.DataLockStatus> GetDataLock(long apprenticeshipId, long dataLockEventId) { _logger.Trace($"Getting data lock: {dataLockEventId} for apprenticeship: {apprenticeshipId}", apprenticeshipId: apprenticeshipId); var response = await _mediator.SendAsync(new GetDataLockRequest { ApprenticeshipId = apprenticeshipId, DataLockEventId = dataLockEventId }); _logger.Info($"Retrieved data lock: {dataLockEventId} for apprenticeship: {apprenticeshipId}", apprenticeshipId: apprenticeshipId); return(_dataLockMapper.Map(response.Data)); }
public async Task <GetOverlappingApprenticeshipsResponse> Handle(GetOverlappingApprenticeshipsRequest query) { var validationResult = _validator.Validate(query); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } var result = new GetOverlappingApprenticeshipsResponse { Data = new List <ApprenticeshipResult>() }; var ulns = query.OverlappingApprenticeshipRequests.Where(x => !string.IsNullOrWhiteSpace(x.Uln)).Select(x => x.Uln).ToList(); if (!ulns.Any()) { return(result); } var apprenticeships = await _apprenticeshipRepository.GetActiveApprenticeshipsByUlns(ulns); foreach (var apprenticeship in apprenticeships) { foreach (var request in query.OverlappingApprenticeshipRequests.Where(x => x.Uln == apprenticeship.Uln)) { var validationFailReason = _overlapRules.DetermineOverlap(request, apprenticeship); if (validationFailReason != ValidationFailReason.None) { _logger.Info($"Validation failed for: {request.StartDate:MMM yyyy} - {request.EndDate:MMM yyyy} Reason: {validationFailReason} " + $"with Apprenticeship Id: {apprenticeship.Id} {apprenticeship.StartDate:MMM yyyy} - {apprenticeship.EndDate:MMM yyyy}"); apprenticeship.ValidationFailReason = validationFailReason; apprenticeship.RequestApprenticeshipId = request.ApprenticeshipId; result.Data.Add(apprenticeship); } } } return(result); }
public async Task <long> UpdateDataLockStatus(DataLockStatus dataLockStatus) { _logger.Info($"Updating or inserting data lock status {dataLockStatus.DataLockEventId}, EventsStatus: {dataLockStatus.EventStatus}"); try { var result = await WithConnection(async connection => { var parameters = new DynamicParameters(); parameters.Add("@DataLockEventId", dataLockStatus.DataLockEventId); parameters.Add("@DataLockEventDatetime", dataLockStatus.DataLockEventDatetime); parameters.Add("@PriceEpisodeIdentifier", dataLockStatus.PriceEpisodeIdentifier); parameters.Add("@ApprenticeshipId", dataLockStatus.ApprenticeshipId); parameters.Add("@IlrTrainingCourseCode", dataLockStatus.IlrTrainingCourseCode); parameters.Add("@IlrTrainingType", dataLockStatus.IlrTrainingType); parameters.Add("@IlrActualStartDate", dataLockStatus.IlrActualStartDate); parameters.Add("@IlrEffectiveFromDate", dataLockStatus.IlrEffectiveFromDate); parameters.Add("@IlrPriceEffectiveToDate", dataLockStatus.IlrPriceEffectiveToDate); parameters.Add("@IlrTotalCost", dataLockStatus.IlrTotalCost); parameters.Add("@ErrorCode", dataLockStatus.ErrorCode); parameters.Add("@Status", dataLockStatus.Status); parameters.Add("@TriageStatus", dataLockStatus.TriageStatus); parameters.Add("@ApprenticeshipUpdateId", dataLockStatus.ApprenticeshipUpdateId); parameters.Add("@IsResolved", dataLockStatus.IsResolved); parameters.Add("@EventStatus", dataLockStatus.EventStatus); return(await connection.ExecuteAsync( sql: $"[dbo].[UpdateDataLockStatus]", param: parameters, commandType: CommandType.StoredProcedure)); }); return(result); } catch (Exception ex) when(ex.InnerException is SqlException && IsConstraintError(ex.InnerException as SqlException)) { throw new RepositoryConstraintException("Unable to insert datalockstatus record", ex); } }
public async Task UpdateApprenticeshipEpa(long apprenticeshipId, string epaOrgId) { _logger.Info($"Updating apprenticeship {apprenticeshipId} EPAOrgId to {epaOrgId ?? "NULL"}"); var rowsAffected = await WithConnection(async connection => { var parameters = new DynamicParameters(); parameters.Add("@id", apprenticeshipId, DbType.Int64); parameters.Add("@EPAOrgId", epaOrgId, DbType.AnsiStringFixedLength); return(await connection.ExecuteAsync( "UPDATE [dbo].[Apprenticeship] SET EPAOrgId = @EPAOrgId " + "WHERE Id = @id;", param: parameters, commandType: CommandType.Text)); }); if (rowsAffected == 0) // best exception to throw? create new ApprenticeshipNotFound or something? { throw new ArgumentOutOfRangeException($"Apprenticeship with Id {apprenticeshipId} not found"); } }
public async Task <IEnumerable <Commitment.CommitmentListItem> > GetCommitments(long accountId) { _logger.Trace($"Getting commitments for employer account {accountId}", accountId: accountId); var response = await _mediator.SendAsync(new GetCommitmentsRequest { Caller = new Caller { CallerType = CallerType.Employer, Id = accountId } }); _logger.Info($"Retrieved commitments for employer account {accountId}. {response.Data?.Count} commitments found", accountId: accountId); return(_commitmentMapper.MapFrom(response.Data, CallerType.Employer)); }
public async Task <IEnumerable <CommitmentListItem> > GetCommitments(long providerId) { _logger.Trace($"Getting commitments for provider {providerId}", providerId: providerId); var response = await _mediator.SendAsync(new GetCommitmentsRequest { Caller = new Caller { CallerType = CallerType.Provider, Id = providerId } }); _logger.Info($"Retrieved commitments for provider {providerId}. {response.Data?.Count} commitments found", providerId: providerId, recordCount: response.Data?.Count); return(_commitmentMapper.MapFrom(response.Data, CallerType.Provider)); }