From 2d66e3170f500ecca84d09e75273cb53ac2716fe Mon Sep 17 00:00:00 2001 From: Oliver Scott Date: Fri, 29 Sep 2023 10:16:34 +0100 Subject: [PATCH] Further reduce complexity --- .../Controllers/HearingsController.cs | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/AdminWebsite/AdminWebsite/Controllers/HearingsController.cs b/AdminWebsite/AdminWebsite/Controllers/HearingsController.cs index a1d7b09c7..c74d3c276 100644 --- a/AdminWebsite/AdminWebsite/Controllers/HearingsController.cs +++ b/AdminWebsite/AdminWebsite/Controllers/HearingsController.cs @@ -273,18 +273,7 @@ public async Task> EditHearing(Guid hearing HearingDetailsResponse originalHearing; try { - - if (_featureToggles.ReferenceDataToggle()) - { - var response = await _bookingsApiClient.GetHearingDetailsByIdV2Async(hearingId); - originalHearing = response.Map(); - } - else - { - - var response = await _bookingsApiClient.GetHearingDetailsByIdAsync(hearingId); - originalHearing = response.Map(); - } + originalHearing = await GetHearing(hearingId); } catch (BookingsApiException e) { @@ -332,6 +321,18 @@ public async Task> EditHearing(Guid hearing } } + private async Task GetHearing(Guid hearingId) + { + if (_featureToggles.ReferenceDataToggle()) + { + var responseV2 = await _bookingsApiClient.GetHearingDetailsByIdV2Async(hearingId); + return responseV2.Map(); + } + + var responseV1 = await _bookingsApiClient.GetHearingDetailsByIdAsync(hearingId); + return responseV1.Map(); + } + private async Task MapHearingToUpdate(Guid hearingId) { if (_featureToggles.ReferenceDataToggle())