diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Controllers/RoadmapController.cs b/AdminUI/LearningHub.Nhs.AdminUI/Controllers/RoadmapController.cs index 319c8938c..bd7261a87 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Controllers/RoadmapController.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/Controllers/RoadmapController.cs @@ -99,7 +99,7 @@ public async Task AddUpdate(UpdateViewModel update) RoadmapTypeId = update.RoadmapTypeId, }; var roadmapId = await this.roadmapService.AddRoadmap(roadmap); - return this.RedirectToAction("EditUpdate", new { id = roadmapId }); + return this.RedirectToAction("Details", new { id = roadmapId }); } /// @@ -160,7 +160,7 @@ public async Task EditUpdate(UpdateViewModel update) Id = update.Id, }; await this.roadmapService.UpdateRoadmap(roadmap); - return this.RedirectToAction("EditUpdate", new { roadmap.Id }); + return this.RedirectToAction("Details", new { roadmap.Id }); } /// @@ -202,6 +202,18 @@ public async Task Updates(string searchTerm = null) return this.View(model); } + /// + /// The Details. + /// + /// The id. + /// The . + [HttpGet] + public async Task Details(int id) + { + var roadmap = await this.roadmapService.GetIdAsync(id); + return this.View(roadmap); + } + /// /// The UploadFile. /// diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IRoadmapService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IRoadmapService.cs index cb96b6037..a0606ebc3 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IRoadmapService.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IRoadmapService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using LearningHub.Nhs.Models.Entities; + using LearningHub.Nhs.Models.RoadMap; /// /// Defines the . @@ -36,6 +37,13 @@ public interface IRoadmapService /// The . Task> GetUpdates(); + /// + /// The GetIdAsync. + /// + /// The id. + /// The . + Task GetIdAsync(int id); + /// /// The UpdateRoadmap. /// diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/RoadmapService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/RoadmapService.cs index bf4878d8b..48507ae31 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Services/RoadmapService.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/RoadmapService.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using LearningHub.Nhs.AdminUI.Interfaces; using LearningHub.Nhs.Models.Entities; + using LearningHub.Nhs.Models.RoadMap; using Newtonsoft.Json; /// @@ -134,6 +135,34 @@ public async Task> GetUpdates() return viewmodel; } + /// + /// The GetIdAsync. + /// + /// The id. + /// The . + public async Task GetIdAsync(int id) + { + RoadMapViewModel viewmodel = null; + + var client = await this.LearningHubHttpClient.GetClientAsync(); + var request = $"Roadmap/GetRoadMapsById/{id}"; + var response = await client.GetAsync(request).ConfigureAwait(false); + + if (response.IsSuccessStatusCode) + { + var result = response.Content.ReadAsStringAsync().Result; + viewmodel = JsonConvert.DeserializeObject(result); + } + else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized + || + response.StatusCode == System.Net.HttpStatusCode.Forbidden) + { + throw new Exception("AccessDenied"); + } + + return viewmodel; + } + /// /// The UpdateRoadmap. /// diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Views/Log/Index.cshtml b/AdminUI/LearningHub.Nhs.AdminUI/Views/Log/Index.cshtml index 8e9c75ae2..8f3eb95d3 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Views/Log/Index.cshtml +++ b/AdminUI/LearningHub.Nhs.AdminUI/Views/Log/Index.cshtml @@ -23,6 +23,8 @@ + @if (Model.Results != null) + { @foreach (var item in Model.Results.Items) { @@ -46,6 +48,7 @@ } + } diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Views/Roadmap/Details.cshtml b/AdminUI/LearningHub.Nhs.AdminUI/Views/Roadmap/Details.cshtml new file mode 100644 index 000000000..983a1abc0 --- /dev/null +++ b/AdminUI/LearningHub.Nhs.AdminUI/Views/Roadmap/Details.cshtml @@ -0,0 +1,98 @@ +@model LearningHub.Nhs.Models.RoadMap.RoadMapViewModel; +@using LearningHub.Nhs.AdminUI.Services + +@{ + ViewData["Title"] = "Details"; +} +@section SideMenu { + @{ + await Html.RenderPartialAsync("_NavSection"); + } +} + +
+
+   Go back +
+ +
+
+ @{ + string noneVal = ""; + } +
+
+
ID @Model.Id
+ @ViewBag.UpdateSaveError +
+
+ Title +
+
+ @Html.DisplayFor(model => model.Title) +
+
+ Date +
+
+ @Html.DisplayFor(model => model.RoadmapDate) +
+
+ Feature Image +
+
+ +
+
+ Description +
+
+ @Html.Raw(Model.Description) +
+
+ Status +
+ + + @if (Model.Published) + { +
+ Published +
+ } + else + { +
+ Not Published +
+ } +
+ Create User +
+
+ @Html.DisplayFor(model => model.CreateUserName) +
+
+ Create Date +
+
+ @Html.DisplayFor(model => model.CreateDate) +
+
+ Amend User +
+
+ @Html.DisplayFor(model => model.AmendUserName) +
+
+ Amend Date +
+
+ @Html.DisplayFor(model => model.AmendDate) +
+
+
+
+ +
+ diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Views/Roadmap/Updates.cshtml b/AdminUI/LearningHub.Nhs.AdminUI/Views/Roadmap/Updates.cshtml index 5a7a801b1..767896ab4 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Views/Roadmap/Updates.cshtml +++ b/AdminUI/LearningHub.Nhs.AdminUI/Views/Roadmap/Updates.cshtml @@ -1,68 +1,70 @@ @model LearningHub.Nhs.Models.Paging.TablePagingViewModel @{ - ViewData["Title"] = "Service updates and releases"; - ViewData["CurrentPage"] = Model.Paging.CurrentPage; - var searchTerm = ViewData["SearchTerm"]; + ViewData["Title"] = "Service updates and releases"; + ViewData["CurrentPage"] = Model.Paging.CurrentPage; + var searchTerm = ViewData["SearchTerm"]; } -@section Styles{ - +@section Styles { + } @section SideMenu { - @{await Html.RenderPartialAsync("_NavSection"); } + @{ + await Html.RenderPartialAsync("_NavSection"); + } }
-
-
- Updates -
+
+ - +
+
- - - - - - +
Published
+ + + + + - - - - @foreach (var item in Model.Results.Items) + + + + @foreach (var item in Model.Results.Items) + { + + + + - - - - + } - -
Published
+ @Html.ActionLink(item.Title.ToString(), "Details", new { id = item.Id }) + + @Html.ActionLink(item.RoadmapDate.Value.ToString("dd MMM yyyy"), "Details", new { id = item.Id }) + + @if (item.Published) { -
- @Html.ActionLink(item.Title.ToString(), "EditUpdate", new { id = item.Id }) - - @Html.ActionLink(item.RoadmapDate.Value.ToString("dd MMM yyyy"), "EditUpdate", new { id = item.Id }) - - @if (item.Published) - { - - } - else - { - - } -
+ else + { + + } + + + } + +
@section Scripts { - - + + } diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_NavSection.cshtml b/AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_NavSection.cshtml index 995e1f42a..924c58475 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_NavSection.cshtml +++ b/AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_NavSection.cshtml @@ -13,9 +13,9 @@ sideMenu = "settings"; break; case "roadmap": + sideMenu = "settings"; if (activeItem.Contains("update")) { - sideMenu = "settings"; controller = "updates"; } break; diff --git a/WebAPI/LearningHub.Nhs.API/Controllers/RoadmapController.cs b/WebAPI/LearningHub.Nhs.API/Controllers/RoadmapController.cs index 3dc4c3c01..1c152a537 100644 --- a/WebAPI/LearningHub.Nhs.API/Controllers/RoadmapController.cs +++ b/WebAPI/LearningHub.Nhs.API/Controllers/RoadmapController.cs @@ -2,8 +2,10 @@ { using System.Collections.Generic; using System.Threading.Tasks; + using AutoMapper; using LearningHub.Nhs.Models.Common; using LearningHub.Nhs.Models.Entities; + using LearningHub.Nhs.Models.Notification; using LearningHub.Nhs.Models.RoadMap; using LearningHub.Nhs.Services.Interface; using Microsoft.AspNetCore.Authorization; @@ -19,6 +21,7 @@ public class RoadmapController : ApiControllerBase { private readonly IRoadmapService roadmapService; + private readonly IMapper mapper; /// /// Initializes a new instance of the class. @@ -26,13 +29,16 @@ public class RoadmapController : ApiControllerBase /// The user service. /// The roadmap service. /// The logger. + /// The mapper. public RoadmapController( IUserService userService, IRoadmapService roadmapService, - ILogger logger) + ILogger logger, + IMapper mapper) : base(userService, logger) { this.roadmapService = roadmapService; + this.mapper = mapper; } /// @@ -71,6 +77,22 @@ public async Task GetRoadmap(int id) return await this.roadmapService.GetRoadmap(id); } + /// + /// The GetRoadmap. + /// + /// The id. + /// The roadmap. + [HttpGet] + [Route("GetRoadMapsById/{id}")] + public async Task GetRoadMapsById(int id) + { + var roadMap = await this.roadmapService.GetRoadmapUser(id); + var roadmapviewmodel = this.mapper.Map(roadMap); + roadmapviewmodel.CreateUserName = roadMap.CreateUser.UserName; + roadmapviewmodel.AmendUserName = roadMap.AmendUser.UserName; + return roadmapviewmodel; + } + /// /// The AddRoadmap. /// diff --git a/WebAPI/LearningHub.Nhs.Services.Interface/IRoadmapService.cs b/WebAPI/LearningHub.Nhs.Services.Interface/IRoadmapService.cs index 26330690f..4d9a1176f 100644 --- a/WebAPI/LearningHub.Nhs.Services.Interface/IRoadmapService.cs +++ b/WebAPI/LearningHub.Nhs.Services.Interface/IRoadmapService.cs @@ -55,6 +55,13 @@ public interface IRoadmapService /// The roadmap. Task GetRoadmap(int id); + /// + /// The get roadmap with Userdetails. + /// + /// The id. + /// The roadmap. + Task GetRoadmapUser(int id); + /// /// The delete roadmap. /// diff --git a/WebAPI/LearningHub.Nhs.Services/RoadmapService.cs b/WebAPI/LearningHub.Nhs.Services/RoadmapService.cs index e3c7f8408..17d9fb8bf 100644 --- a/WebAPI/LearningHub.Nhs.Services/RoadmapService.cs +++ b/WebAPI/LearningHub.Nhs.Services/RoadmapService.cs @@ -107,6 +107,21 @@ public async Task GetRoadmap(int id) return await this.roadmapRepository.GetAll().SingleAsync(x => x.Id == id); } + /// + /// The get roadmap with Userdetails. + /// + /// The id. + /// The roadmap. + public async Task GetRoadmapUser(int id) + { + return await this.roadmapRepository.GetAll() + .Include(n => n.AmendUser) + .Include(n => n.CreateUser) + .Where(n => n.Id == id) + .AsNoTracking() + .SingleOrDefaultAsync(); + } + /// /// The delete roadmap. ///