public async Task <bool> Handle(UpdateOrganisationProviderTypeRequest request, CancellationToken cancellationToken) { ValidateUpdateProviderTypeRequest(request); _logger.LogInformation($@"Handling Update '{FieldChanged}' for Organisation ID [{request.OrganisationId}]"); var auditData = _auditLogService.AuditProviderType(request.OrganisationId, request.UpdatedBy, request.ProviderTypeId, request.OrganisationTypeId); var success = false; if (!auditData.ChangesMade) { return(await Task.FromResult(false)); } if (auditData.FieldChanges.Any(x => x.FieldChanged == AuditLogField.ProviderType)) { success = await _updateOrganisationRepository.UpdateProviderType(request.OrganisationId, request.ProviderTypeId, request.UpdatedBy); } if (success && auditData.FieldChanges.Any(x => x.FieldChanged == AuditLogField.OrganisationType)) { success = await _updateOrganisationRepository.UpdateOrganisationType(request.OrganisationId, request.OrganisationTypeId, request.UpdatedBy); } if (success && auditData.FieldChanges.Any(x => x.FieldChanged == AuditLogField.OrganisationStatus)) { success = await _updateOrganisationRepository.UpdateOrganisationStatus(request.OrganisationId, OrganisationStatus.Active, request.UpdatedBy); } if (success && auditData.FieldChanges.Any(x => x.FieldChanged == AuditLogField.StartDate)) { success = await _updateOrganisationRepository.UpdateStartDate(request.OrganisationId, DateTime.Today, request.UpdatedBy); } if (success) { return(await _updateOrganisationRepository.WriteFieldChangesToAuditLog(auditData)); } return(await Task.FromResult(false)); }