Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #790 from DFE-Digital/feature/transfer-dates-and-h…
Browse files Browse the repository at this point in the history
…istory

Fixed bug where it would throw on null date history
  • Loading branch information
dneed-nimble authored Jul 3, 2024
2 parents 57eb586 + 3823257 commit 1f0d37b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Dfe.PrepareTransfers.Data.TRAMS/TramsProjectsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,10 @@ public async Task<IEnumerable<OpeningDateHistoryDto>> GetOpeningDateHistory(int
var apiResponse = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<IEnumerable<OpeningDateHistoryDto>>(apiResponse);
}

if (response.StatusCode is System.Net.HttpStatusCode.NotFound)
{
return null;
}
throw new TramsApiException(response);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class DateHistory : CommonPageModel

public Project Project { get; set; }
public AdvisoryBoardDecision Decision { get; set; }
public IEnumerable<OpeningDateHistoryDto> OpeningDateHistory { get; set; }
public IEnumerable<OpeningDateHistoryDto>? OpeningDateHistory { get; set; }

public DateHistory(IProjects projectsRepository, ILogger<DateHistory> logger)
{
Expand All @@ -28,7 +28,7 @@ public DateHistory(IProjects projectsRepository, ILogger<DateHistory> logger)
public async Task<IActionResult> OnGetAsync()
{
Project = (await _projectsRepository.GetByUrn(Urn)).Result;
OpeningDateHistory = await _projectsRepository.GetOpeningDateHistory(Convert.ToInt32(Urn));
OpeningDateHistory = await _projectsRepository.GetOpeningDateHistory(Convert.ToInt32(Urn)) ?? null;

return Page();
}
Expand Down

0 comments on commit 1f0d37b

Please sign in to comment.