private async Task AddEndpointToHearing(Guid hearingId, HearingDetailsResponse hearing, EditEndpointRequest endpoint) { _logger.LogDebug("Adding endpoint {EndpointDisplayName} to hearing {Hearing}", endpoint.DisplayName, hearingId); var addEndpointRequest = new AddEndpointRequest { DisplayName = endpoint.DisplayName, DefenceAdvocateUsername = endpoint.DefenceAdvocateUsername }; await _bookingsApiClient.AddEndPointToHearingAsync(hearing.Id, addEndpointRequest); }
private async Task UpdateEndpointInHearing(Guid hearingId, HearingDetailsResponse hearing, EditEndpointRequest endpoint) { var existingEndpointToEdit = hearing.Endpoints.FirstOrDefault(e => e.Id.Equals(endpoint.Id)); if (existingEndpointToEdit == null || existingEndpointToEdit.DisplayName == endpoint.DisplayName && existingEndpointToEdit.DefenceAdvocateId.ToString() == endpoint.DefenceAdvocateUsername) { return; } _logger.LogDebug("Updating endpoint {Endpoint} - {EndpointDisplayName} in hearing {Hearing}", existingEndpointToEdit.Id, existingEndpointToEdit.DisplayName, hearingId); var updateEndpointRequest = new UpdateEndpointRequest { DisplayName = endpoint.DisplayName, DefenceAdvocateUsername = endpoint.DefenceAdvocateUsername }; await _bookingsApiClient.UpdateDisplayNameForEndpointAsync(hearing.Id, endpoint.Id.Value, updateEndpointRequest); }