Skip to content

Commit

Permalink
Further reduce complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-scott committed Sep 29, 2023
1 parent 6a8425c commit 2d66e31
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions AdminWebsite/AdminWebsite/Controllers/HearingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,7 @@ public async Task<ActionResult<HearingDetailsResponse>> 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)
{
Expand Down Expand Up @@ -332,6 +321,18 @@ public async Task<ActionResult<HearingDetailsResponse>> EditHearing(Guid hearing
}
}

private async Task<HearingDetailsResponse> 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<HearingDetailsResponse> MapHearingToUpdate(Guid hearingId)
{
if (_featureToggles.ReferenceDataToggle())
Expand Down

0 comments on commit 2d66e31

Please sign in to comment.