From e89af4f5dee603914f5a92db0d460496e63e1cf2 Mon Sep 17 00:00:00 2001 From: "NM2.8EMIUBIZ" Date: Thu, 19 Mar 2026 15:39:27 +0000 Subject: [PATCH] TD-6612: Integrated Roadmap API into WebUI --- .../Controllers/JiraRoadmapController.cs | 50 ++++++++++++++++++ .../Interfaces/IJiraRoadmapService.cs | 18 +++++++ .../Services/JiraRoadmapService.cs | 52 +++++++++++++++++++ .../Startup/ServiceMappings.cs | 1 + 4 files changed, 121 insertions(+) create mode 100644 LearningHub.Nhs.WebUI/Controllers/JiraRoadmapController.cs create mode 100644 LearningHub.Nhs.WebUI/Interfaces/IJiraRoadmapService.cs create mode 100644 LearningHub.Nhs.WebUI/Services/JiraRoadmapService.cs diff --git a/LearningHub.Nhs.WebUI/Controllers/JiraRoadmapController.cs b/LearningHub.Nhs.WebUI/Controllers/JiraRoadmapController.cs new file mode 100644 index 000000000..eec6515d8 --- /dev/null +++ b/LearningHub.Nhs.WebUI/Controllers/JiraRoadmapController.cs @@ -0,0 +1,50 @@ +namespace LearningHub.Nhs.WebUI.Controllers +{ + using System.Net.Http; + using System.Threading.Tasks; + using LearningHub.Nhs.WebUI.Configuration; + using LearningHub.Nhs.WebUI.Interfaces; + using Microsoft.AspNetCore.Hosting; + using Microsoft.AspNetCore.Mvc; + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Options; + + /// + /// Defines the . + /// + public class JiraRoadmapController : BaseController + { + private readonly IJiraRoadmapService jiraRoadmapService; + + /// + /// Initializes a new instance of the class. + /// + /// hostingEnvironment. + /// logger. + /// settings. + /// httpClientFactory. + /// jiraRoadmapService. + public JiraRoadmapController( + IWebHostEnvironment hostingEnvironment, + ILogger logger, + IOptions settings, + IHttpClientFactory httpClientFactory, + IJiraRoadmapService jiraRoadmapService) + : base(hostingEnvironment, httpClientFactory, logger, settings.Value) + { + this.jiraRoadmapService = jiraRoadmapService; + } + + /// + /// Returns public roadmap issues (data only endpoint for WebUI). + /// + /// The . + [HttpGet] + [Route("getRoadmapIssues")] + public async Task GetRoadmapIssues() + { + var roadmapResponse = await this.jiraRoadmapService.GetPublicRoadmapIssues(); + return this.Json(roadmapResponse); + } + } +} diff --git a/LearningHub.Nhs.WebUI/Interfaces/IJiraRoadmapService.cs b/LearningHub.Nhs.WebUI/Interfaces/IJiraRoadmapService.cs new file mode 100644 index 000000000..610846970 --- /dev/null +++ b/LearningHub.Nhs.WebUI/Interfaces/IJiraRoadmapService.cs @@ -0,0 +1,18 @@ +namespace LearningHub.Nhs.WebUI.Interfaces +{ + using System.Collections.Generic; + using System.Threading.Tasks; + using LearningHub.Nhs.Models.JiraRoadmap; + + /// + /// Defines the . + /// + public interface IJiraRoadmapService + { + /// + /// Gets public roadmap issues from Jira Open API. + /// + /// The . + Task GetPublicRoadmapIssues(); + } +} diff --git a/LearningHub.Nhs.WebUI/Services/JiraRoadmapService.cs b/LearningHub.Nhs.WebUI/Services/JiraRoadmapService.cs new file mode 100644 index 000000000..49b3aebf3 --- /dev/null +++ b/LearningHub.Nhs.WebUI/Services/JiraRoadmapService.cs @@ -0,0 +1,52 @@ +namespace LearningHub.Nhs.WebUI.Services +{ + using System; + using System.Threading.Tasks; + using LearningHub.Nhs.Models.JiraRoadmap; + using LearningHub.Nhs.WebUI.Interfaces; + using Microsoft.Extensions.Logging; + using Newtonsoft.Json; + + /// + /// Defines the . + /// + public class JiraRoadmapService : BaseService, IJiraRoadmapService + { + /// + /// Initializes a new instance of the class. + /// + /// The learningHubHttpClient. + /// The openApiHttpClient. + /// The logger. + public JiraRoadmapService( + ILearningHubHttpClient learningHubHttpClient, + IOpenApiHttpClient openApiHttpClient, + ILogger logger) + : base(learningHubHttpClient, openApiHttpClient, logger) + { + } + + /// + public async Task GetPublicRoadmapIssues() + { + var client = await this.OpenApiHttpClient.GetClientAsync(); + var request = "JiraRoadmap/GetRoadmapIssues"; + var response = await client.GetAsync(request).ConfigureAwait(false); + if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized + || + response.StatusCode == System.Net.HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + RoadmapResponseDto roadmapResponse = new RoadmapResponseDto(); + if (response.IsSuccessStatusCode) + { + var result = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + roadmapResponse = JsonConvert.DeserializeObject(result); + } + + return roadmapResponse; + } + } +} \ No newline at end of file diff --git a/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs b/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs index 26f75aeb1..c3cbf096c 100644 --- a/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs +++ b/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs @@ -115,6 +115,7 @@ public static void AddLearningHubMappings(this IServiceCollection services, ICon services.AddSingleton(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); // Filters (that require DI) services.AddScoped();