Skip to content

Commit 8a2549e

Browse files
committed
TD-5048: Issue showing multiple entries for service updates/releases on 'Admin' section when clicked 'save' button multiple times
1 parent c881bdd commit 8a2549e

File tree

10 files changed

+248
-52
lines changed

10 files changed

+248
-52
lines changed

AdminUI/LearningHub.Nhs.AdminUI/Controllers/RoadmapController.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public async Task<IActionResult> AddUpdate(UpdateViewModel update)
9999
RoadmapTypeId = update.RoadmapTypeId,
100100
};
101101
var roadmapId = await this.roadmapService.AddRoadmap(roadmap);
102-
return this.RedirectToAction("EditUpdate", new { id = roadmapId });
102+
return this.RedirectToAction("Details", new { id = roadmapId });
103103
}
104104

105105
/// <summary>
@@ -160,7 +160,7 @@ public async Task<IActionResult> EditUpdate(UpdateViewModel update)
160160
Id = update.Id,
161161
};
162162
await this.roadmapService.UpdateRoadmap(roadmap);
163-
return this.RedirectToAction("EditUpdate", new { roadmap.Id });
163+
return this.RedirectToAction("Details", new { roadmap.Id });
164164
}
165165

166166
/// <summary>
@@ -202,6 +202,18 @@ public async Task<IActionResult> Updates(string searchTerm = null)
202202
return this.View(model);
203203
}
204204

205+
/// <summary>
206+
/// The Details.
207+
/// </summary>
208+
/// <param name="id">The id<see cref="int"/>.</param>
209+
/// <returns>The <see cref="Task{IActionResult}"/>.</returns>
210+
[HttpGet]
211+
public async Task<IActionResult> Details(int id)
212+
{
213+
var roadmap = await this.roadmapService.GetIdAsync(id);
214+
return this.View(roadmap);
215+
}
216+
205217
/// <summary>
206218
/// The UploadFile.
207219
/// </summary>

AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IRoadmapService.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Threading.Tasks;
55
using LearningHub.Nhs.Models.Entities;
6+
using LearningHub.Nhs.Models.RoadMap;
67

78
/// <summary>
89
/// Defines the <see cref="IRoadmapService" />.
@@ -36,6 +37,13 @@ public interface IRoadmapService
3637
/// <returns>The <see cref="List{Roadmap}"/>.</returns>
3738
Task<List<Roadmap>> GetUpdates();
3839

40+
/// <summary>
41+
/// The GetIdAsync.
42+
/// </summary>
43+
/// <param name="id">The id<see cref="int"/>.</param>
44+
/// <returns>The <see cref="Task{Roadmap}"/>.</returns>
45+
Task<RoadMapViewModel> GetIdAsync(int id);
46+
3947
/// <summary>
4048
/// The UpdateRoadmap.
4149
/// </summary>

AdminUI/LearningHub.Nhs.AdminUI/Services/RoadmapService.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Threading.Tasks;
88
using LearningHub.Nhs.AdminUI.Interfaces;
99
using LearningHub.Nhs.Models.Entities;
10+
using LearningHub.Nhs.Models.RoadMap;
1011
using Newtonsoft.Json;
1112

1213
/// <summary>
@@ -134,6 +135,34 @@ public async Task<List<Roadmap>> GetUpdates()
134135
return viewmodel;
135136
}
136137

138+
/// <summary>
139+
/// The GetIdAsync.
140+
/// </summary>
141+
/// <param name="id">The id<see cref="int"/>.</param>
142+
/// <returns>The <see cref="Task{Roadmap}"/>.</returns>
143+
public async Task<RoadMapViewModel> GetIdAsync(int id)
144+
{
145+
RoadMapViewModel viewmodel = null;
146+
147+
var client = await this.LearningHubHttpClient.GetClientAsync();
148+
var request = $"Roadmap/GetRoadMapsById/{id}";
149+
var response = await client.GetAsync(request).ConfigureAwait(false);
150+
151+
if (response.IsSuccessStatusCode)
152+
{
153+
var result = response.Content.ReadAsStringAsync().Result;
154+
viewmodel = JsonConvert.DeserializeObject<RoadMapViewModel>(result);
155+
}
156+
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
157+
||
158+
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
159+
{
160+
throw new Exception("AccessDenied");
161+
}
162+
163+
return viewmodel;
164+
}
165+
137166
/// <summary>
138167
/// The UpdateRoadmap.
139168
/// </summary>

AdminUI/LearningHub.Nhs.AdminUI/Views/Log/Index.cshtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
</tr>
2424
</thead>
2525
<tbody>
26+
@if (Model.Results != null)
27+
{
2628
@foreach (var item in Model.Results.Items)
2729
{
2830
<tr>
@@ -46,6 +48,7 @@
4648
</td>
4749
</tr>
4850
}
51+
}
4952
</tbody>
5053
</table>
5154
</div>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
@model LearningHub.Nhs.Models.RoadMap.RoadMapViewModel;
2+
@using LearningHub.Nhs.AdminUI.Services
3+
4+
@{
5+
ViewData["Title"] = "Details";
6+
}
7+
@section SideMenu {
8+
@{
9+
await Html.RenderPartialAsync("_NavSection");
10+
}
11+
}
12+
13+
<div class="panel-body admin-body">
14+
<div class="d-flex flex-row justify-content-between col-12">
15+
<a href="@Url.Action("Updates", "Roadmap")" class="pl-3"><i class="fa-solid fa-chevron-left">&nbsp;</i> Go back</a>
16+
<div class="admin-title right-side">
17+
<button type="button" class="btn btn-admin" onclick="location.href='@Url.Action("EditUpdate", "Roadmap", new { id = Model.Id })'"><i class="fa-solid fa-pencil"></i> Edit</button>
18+
</div>
19+
</div>
20+
@{
21+
string noneVal = "";
22+
}
23+
<div class="admin-section">
24+
<div class="col-12">
25+
<div class="id-container">ID @Model.Id</div>
26+
@ViewBag.UpdateSaveError
27+
<dl>
28+
<dt>
29+
Title
30+
</dt>
31+
<dd>
32+
@Html.DisplayFor(model => model.Title)
33+
</dd>
34+
<dt>
35+
Date
36+
</dt>
37+
<dd>
38+
@Html.DisplayFor(model => model.RoadmapDate)
39+
</dd>
40+
<dt>
41+
Feature Image
42+
</dt>
43+
<dd>
44+
<img src="/file/download/RoadmapImage/@Model.ImageName" style="width: 100px; height: 60px" class="mt-1" />
45+
</dd>
46+
<dt>
47+
Description
48+
</dt>
49+
<dd>
50+
@Html.Raw(Model.Description)
51+
</dd>
52+
<dt>
53+
Status
54+
</dt>
55+
56+
57+
@if (Model.Published)
58+
{
59+
<dd>
60+
Published
61+
</dd>
62+
}
63+
else
64+
{
65+
<dd>
66+
Not Published
67+
</dd>
68+
}
69+
<dt>
70+
Create User
71+
</dt>
72+
<dd>
73+
@Html.DisplayFor(model => model.CreateUserName)
74+
</dd>
75+
<dt>
76+
Create Date
77+
</dt>
78+
<dd>
79+
@Html.DisplayFor(model => model.CreateDate)
80+
</dd>
81+
<dt>
82+
Amend User
83+
</dt>
84+
<dd>
85+
@Html.DisplayFor(model => model.AmendUserName)
86+
</dd>
87+
<dt>
88+
Amend Date
89+
</dt>
90+
<dd>
91+
@Html.DisplayFor(model => model.AmendDate)
92+
</dd>
93+
</dl>
94+
</div>
95+
</div>
96+
97+
</div>
98+
Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,70 @@
11
@model LearningHub.Nhs.Models.Paging.TablePagingViewModel<LearningHub.Nhs.Models.Entities.Roadmap>
22
@{
3-
ViewData["Title"] = "Service updates and releases";
4-
ViewData["CurrentPage"] = Model.Paging.CurrentPage;
5-
var searchTerm = ViewData["SearchTerm"];
3+
ViewData["Title"] = "Service updates and releases";
4+
ViewData["CurrentPage"] = Model.Paging.CurrentPage;
5+
var searchTerm = ViewData["SearchTerm"];
66
}
77

8-
@section Styles{
9-
<link href="~/css/Pages/update.css" type="text/css" rel="stylesheet" />
8+
@section Styles {
9+
<link href="~/css/Pages/update.css" type="text/css" rel="stylesheet" />
1010
}
1111

1212
@section SideMenu {
13-
@{await Html.RenderPartialAsync("_NavSection"); }
13+
@{
14+
await Html.RenderPartialAsync("_NavSection");
15+
}
1416
}
1517

1618
<div class="row">
17-
<div class="col roadmap-tab-bar d-flex justify-content-start">
18-
<div class="active">
19-
<a>Updates</a>
20-
</div>
19+
<div class="col roadmap-tab-bar d-flex justify-content-start">
20+
<div class="active">
21+
<a>Updates</a>
2122
</div>
22-
<button id="add-update" class="btn btn-custom-green" onclick="window.location.href = '/Roadmap/AddUpdate'"><i class="fa fa-plus"></i> Add</button>
23+
</div>
24+
<button id="add-update" class="btn btn-custom-green" onclick="window.location.href = '/Roadmap/AddUpdate'"><i class="fa fa-plus"></i> Add</button>
2325
</div>
2426
<div class="table-responsive">
25-
<table class="table table-striped lh-datatable filtered">
26-
<thead>
27-
<tr>
28-
<th style="width: 75%;"><div class="input-group"><input type="text" class="form-control" id="update-search-input" /><span id="update-search-button"><i class="fa fa-search"></i></span></div></th>
29-
<th style="width: 15%;"></th>
30-
<th style="width: 10%">Published</th>
27+
<table class="table table-striped lh-datatable filtered">
28+
<thead>
29+
<tr>
30+
<th style="width: 75%;"><div class="input-group"><input type="text" class="form-control" id="update-search-input" /><span id="update-search-button"><i class="fa fa-search"></i></span></div></th>
31+
<th style="width: 15%;"></th>
32+
<th style="width: 10%">Published</th>
3133

32-
</tr>
33-
</thead>
34-
<tbody>
35-
@foreach (var item in Model.Results.Items)
34+
</tr>
35+
</thead>
36+
<tbody>
37+
@foreach (var item in Model.Results.Items)
38+
{
39+
<tr>
40+
<td>
41+
@Html.ActionLink(item.Title.ToString(), "Details", new { id = item.Id })
42+
</td>
43+
<td>
44+
@Html.ActionLink(item.RoadmapDate.Value.ToString("dd MMM yyyy"), "Details", new { id = item.Id })
45+
</td>
46+
<td>
47+
@if (item.Published)
3648
{
37-
<tr>
38-
<td>
39-
@Html.ActionLink(item.Title.ToString(), "EditUpdate", new { id = item.Id })
40-
</td>
41-
<td>
42-
@Html.ActionLink(item.RoadmapDate.Value.ToString("dd MMM yyyy"), "EditUpdate", new { id = item.Id })
43-
</td>
44-
<td>
45-
@if (item.Published)
46-
{
47-
<i class="fa fa-check"></i>
48-
}
49-
else
50-
{
51-
<i class="fa fa-times"></i>
52-
}
53-
</td>
54-
</tr>
49+
<i class="fa fa-check"></i>
5550
}
56-
</tbody>
57-
</table>
51+
else
52+
{
53+
<i class="fa fa-times"></i>
54+
}
55+
</td>
56+
</tr>
57+
}
58+
</tbody>
59+
</table>
5860
</div>
5961

6062
@section Scripts {
61-
<script src="~/js/pagingContol.js"></script>
62-
<script>
63-
$('#update-search-button').on('click', function () {
64-
var searchTerm = $('#update-search-input').val();
65-
window.location.href = "/Roadmap/Updates?searchTerm=" + encodeURIComponent(searchTerm);
66-
});
67-
</script>
63+
<script src="~/js/pagingContol.js"></script>
64+
<script>
65+
$('#update-search-button').on('click', function () {
66+
var searchTerm = $('#update-search-input').val();
67+
window.location.href = "/Roadmap/Updates?searchTerm=" + encodeURIComponent(searchTerm);
68+
});
69+
</script>
6870
}

AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_NavSection.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
sideMenu = "settings";
1414
break;
1515
case "roadmap":
16+
sideMenu = "settings";
1617
if (activeItem.Contains("update"))
1718
{
18-
sideMenu = "settings";
1919
controller = "updates";
2020
}
2121
break;

0 commit comments

Comments
 (0)