Skip to content

Commit

Permalink
added judge update handler with no notification
Browse files Browse the repository at this point in the history
  • Loading branch information
marcogagliardi committed Mar 4, 2024
1 parent 95b1e2c commit 5912f53
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace BookingQueueSubscriber.Services.IntegrationEvents
{
public class JudgeUpdatedNoNotificationIntegrationEvent : IIntegrationEvent
{
public HearingDto Hearing { get; set; }
public ParticipantDto Judge { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using BookingQueueSubscriber.Services.Mappers;
using BookingQueueSubscriber.Services.VideoApi;

namespace BookingQueueSubscriber.Services.MessageHandlers
{
public class JudgeUpdatedNoNotificationHandler : IMessageHandler<JudgeUpdatedNoNotificationIntegrationEvent>
{
private readonly IVideoApiService _apiService;
private readonly ILogger _logger;

public JudgeUpdatedNoNotificationHandler(IVideoApiService apiService, ILogger logger)
{
_logger = logger;
_apiService = apiService;
}

public async Task HandleAsync(JudgeUpdatedNoNotificationIntegrationEvent eventMessage)
{
var conferenceResponse = await _apiService.GetConferenceByHearingRefId(eventMessage.Hearing.HearingId, true);
var judgeResponse = conferenceResponse.Participants.SingleOrDefault(x => x.RefId == eventMessage.Judge.ParticipantId);

if (judgeResponse != null)
{
var request = ParticipantToUpdateParticipantMapper.MapToParticipantRequest(eventMessage.Judge);
await _apiService.UpdateParticipantDetails(conferenceResponse.Id, judgeResponse.Id, request);
}
else
_logger.LogError("Unable to find judge participant by ref id {ParticipantRefId} in {ConferenceId}", eventMessage.Judge.ParticipantId, conferenceResponse.Id);
}


async Task IMessageHandler.HandleAsync(object integrationEvent) => await HandleAsync((JudgeUpdatedNoNotificationIntegrationEvent)integrationEvent);

}
}

0 comments on commit 5912f53

Please sign in to comment.