Skip to content

Commit a9c85bd

Browse files
authored
Merge pull request #753 from TechnologyEnhancedLearning/Merge-Begonia-Rc
Merge begonia release changes to RC
2 parents c881bdd + 15e6706 commit a9c85bd

File tree

121 files changed

+2150
-1442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+2150
-1442
lines changed

.github/pull_request_template.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
### JIRA link
2-
_TD-###_
2+
[TD-####](https://hee-tis.atlassian.net/browse/TD-####)
33

44
### Description
5-
_Describe what has changed and how that will affect the app. If relevant, add references to the resources you used. Use this as your opportunity to highlight anything odd and give people context around particular decisions._
5+
_Describe what has changed and how that will affect the app. If relevant, add links to any sources/documentation you used. Highlight anything unusual and give people context around particular decisions._
66

77
### Screenshots
8-
_Attach screenshots on mobile, tablet and desktop._
8+
_Paste screenshots for all views created or changed: mobile, tablet and desktop, wave analyser showing no errors._
99

1010
-----
1111
### Developer checks
1212
(Leave tasks unticked if they haven't been appropriate for your ticket.)
1313

1414
I have:
15-
- [ ] Run the formatter and made sure there are no IDE errors
16-
- [ ] Written appropriate unit tests for the changes, including:
17-
- accessibility tests for new views
18-
- tests for new controller methods
19-
- tests for new or modified API endpoints
20-
- [ ] Manually tested my work with and without JavaScript
21-
- [ ] Tested any Views or partials created or changed with [Wave Chrome plugin](https://chrome.google.com/webstore/detail/wave-evaluation-tool/jbbplnpkjmmeebjpijfedlgcdilocofh/related) and addressed any valid accessibility issues
22-
- [ ] Updated/added documentation in [Confluence](https://hee-tis.atlassian.net/wiki/spaces/TP/pages/3477930003/Learning+Hub) and/or [GitHub Readme](https://github.com/TechnologyEnhancedLearning/LearningHub.Nhs.UserApi/blob/master/README.md). List of documentation links added/changed:
15+
- [ ] Run the IDE auto formatter on all files I’ve worked on and made sure there are no IDE errors relating to them
16+
- [ ] Written or updated tests for the changes (accessibility ui tests for views, tests for controller, data services, services, view models created or modified) and made sure all tests are passing
17+
- [ ] Manually tested my work with and without JavaScript (adding notes where functionality requires JavaScript)
18+
- [ ] Tested any Views or partials created or changed with [Wave Chrome plugin](https://chrome.google.com/webstore/detail/wave-evaluation-tool/jbbplnpkjmmeebjpijfedlgcdilocofh/related). Addressed any valid accessibility issues and documented any invalid errors
19+
- [ ] Updated my Jira ticket with testing notes, including information about other parts of the system that were touched as part of the MR and need to be tested to ensure nothing is broken
20+
- [ ] Scanned over my pull request in GitHub and addressed any warnings from the GitHub Build and Test checks in the GitHub PR ‘Files Changed’ tab
21+
Either:
22+
- [ ] Documented my work in [Confluence](https://hee-tis.atlassian.net/wiki/spaces/TP/pages/3461087233/Development), updating any business rules applied or modified. Updated GitHub readme/documentation for the repository if appropriate. List of documentation links added/changed:
2323
- [doc_1_here](link_1_here)
24-
- [ ] Updated my Jira ticket with information about other parts of the system that were touched as part of the MR and have to be sanity tested to ensure nothing is broken
25-
- [ ] Scanned over my pull request in GitHub and addressed any warnings from the GitHub Build and Test checks.
24+
Or:
25+
- [ ] Confirmed that none of the work that I have undertaken requires any updates to documentation

AdminUI/LearningHub.Nhs.AdminUI/Controllers/ResourceController.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,15 @@ public ResourceController(
9191
/// The Details.
9292
/// </summary>
9393
/// <param name="id">The id<see cref="int"/>.</param>
94+
/// <param name="activeTab">The activeTab<see cref="string"/>.</param>
95+
/// <param name="status">The status<see cref="string"/>.</param>
9496
/// <returns>The <see cref="Task{IActionResult}"/>.</returns>
9597
[HttpGet]
96-
public async Task<IActionResult> Details(int id)
98+
public async Task<IActionResult> Details(int id, string activeTab = "details", string status = "")
9799
{
98100
var resource = await this.resourceService.GetResourceVersionExtendedViewModelAsync(id);
101+
this.ViewBag.ActiveTab = activeTab;
102+
this.ViewBag.Status = status;
99103
return this.View(resource);
100104
}
101105

@@ -138,6 +142,41 @@ public async Task<IActionResult> GetValidationResults(int resourceVersionId)
138142
return this.PartialView("_ValidationResults", vm);
139143
}
140144

145+
/// <summary>
146+
/// The GetDevIdDetails.
147+
/// </summary>
148+
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
149+
/// <returns>The <see cref="Task{IActionResult}"/>.</returns>
150+
[HttpPost]
151+
public async Task<IActionResult> GetDevIdDetails(int resourceVersionId)
152+
{
153+
var vm = await this.resourceService.GetResourceVersionDevIdDetailsAsync(resourceVersionId);
154+
155+
return this.PartialView("_DevIdDetails", vm);
156+
}
157+
158+
/// <summary>
159+
/// The update the dev Id details.
160+
/// </summary>
161+
/// <param name="model">The model.</param>
162+
/// <returns>The <see cref="Task{IActionResult}"/>.</returns>
163+
[HttpPost]
164+
public async Task<IActionResult> UpdateDevIdDetails(ResourceVersionDevIdViewModel model)
165+
{
166+
var message = string.Empty;
167+
if (await this.resourceService.DoesDevIdExistsAsync(model.DevId))
168+
{
169+
message = "Duplicate";
170+
}
171+
else
172+
{
173+
await this.resourceService.UpdateDevIdDetailsAsync(model);
174+
message = "Success";
175+
}
176+
177+
return this.RedirectToAction("Details", new { id = model.ResourceVersionId, activeTab = "devId", status = message });
178+
}
179+
141180
/// <summary>
142181
/// The Index.
143182
/// </summary>

AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,30 @@ public interface IResourceService
3232
/// The GetResourceVersionValidationResultAsync.
3333
/// </summary>
3434
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
35-
/// <returns>The <see cref="Task{ResourceVersionEventViewModel}}"/>.</returns>
35+
/// <returns>The <see cref="Task{ResourceVersionValidationResultViewModel}}"/>.</returns>
3636
Task<ResourceVersionValidationResultViewModel> GetResourceVersionValidationResultAsync(int resourceVersionId);
3737

38+
/// <summary>
39+
/// The GetResourceVersionDevIdDetailsAsync.
40+
/// </summary>
41+
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
42+
/// <returns>The <see cref="Task{ResourceVersionDevIdViewModel}}"/>.</returns>
43+
Task<ResourceVersionDevIdViewModel> GetResourceVersionDevIdDetailsAsync(int resourceVersionId);
44+
45+
/// <summary>
46+
/// Check dev id already exist against a resource.
47+
/// </summary>
48+
/// <param name="devId">string devId.</param>
49+
/// <returns>The <see cref="Task{bool}"/>.</returns>
50+
Task<bool> DoesDevIdExistsAsync(string devId);
51+
52+
/// <summary>
53+
/// To update dev id details for a resource.
54+
/// </summary>
55+
/// <param name="model">the ResourceVersionDevIdViewModel.</param>
56+
/// <returns>The <see cref="Task{ResourceVersionDevIdViewModel}}"/>.</returns>
57+
Task UpdateDevIdDetailsAsync(ResourceVersionDevIdViewModel model);
58+
3859
/// <summary>
3960
/// The GetResourceVersionExtendedViewModelAsync.
4061
/// </summary>

AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<PackageReference Include="HtmlSanitizer" Version="6.0.453" />
9090
<PackageReference Include="IdentityModel" Version="4.4.0" />
9191
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
92-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.43" />
92+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.44" />
9393
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
9494
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.0" />
9595
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />

AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using System;
44
using System.Collections.Generic;
5+
using System.Net;
56
using System.Net.Http;
67
using System.Text;
78
using System.Threading.Tasks;
@@ -130,6 +131,89 @@ public async Task<ResourceVersionValidationResultViewModel> GetResourceVersionVa
130131
return viewmodel;
131132
}
132133

134+
/// <summary>
135+
/// The GetResourceVersionDevIdDetailsAsync.
136+
/// </summary>
137+
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
138+
/// <returns>The <see cref="List{ResourceVersionDevIdViewModel}"/>.</returns>
139+
public async Task<ResourceVersionDevIdViewModel> GetResourceVersionDevIdDetailsAsync(int resourceVersionId)
140+
{
141+
ResourceVersionDevIdViewModel viewmodel = null;
142+
143+
var client = await this.LearningHubHttpClient.GetClientAsync();
144+
145+
var request = $"Resource/GetResourceVersionDevIdDetails/{resourceVersionId.ToString()}";
146+
var response = await client.GetAsync(request).ConfigureAwait(false);
147+
148+
if (response.IsSuccessStatusCode)
149+
{
150+
var result = response.Content.ReadAsStringAsync().Result;
151+
viewmodel = JsonConvert.DeserializeObject<ResourceVersionDevIdViewModel>(result);
152+
}
153+
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
154+
||
155+
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
156+
{
157+
throw new Exception("AccessDenied");
158+
}
159+
160+
return viewmodel;
161+
}
162+
163+
/// <summary>
164+
/// The GetResourceVersionDevIdDetailsAsync.
165+
/// </summary>
166+
/// <param name="devId">The devId<see cref="string"/>.</param>
167+
/// <returns>The <see cref="List{ResourceVersionDevIdViewModel}"/>.</returns>
168+
public async Task<bool> DoesDevIdExistsAsync(string devId)
169+
{
170+
var client = await this.LearningHubHttpClient.GetClientAsync();
171+
172+
var request = $"Resource/DoesDevIdExists/{devId}";
173+
var response = await client.GetAsync(request).ConfigureAwait(false);
174+
var doesDevIdExist = false;
175+
if (response.IsSuccessStatusCode)
176+
{
177+
var result = response.Content.ReadAsStringAsync().Result;
178+
doesDevIdExist = JsonConvert.DeserializeObject<bool>(result);
179+
}
180+
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
181+
||
182+
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
183+
{
184+
throw new Exception("AccessDenied");
185+
}
186+
187+
return doesDevIdExist;
188+
}
189+
190+
/// <summary>
191+
/// Update dev id details for a resource.
192+
/// </summary>
193+
/// <param name="model">The model.</param>
194+
/// <returns>The <see cref="List{ResourceVersionDevIdViewModel}"/>.</returns>
195+
/// <exception cref="Exception">the exception.</exception>
196+
public async Task UpdateDevIdDetailsAsync(ResourceVersionDevIdViewModel model)
197+
{
198+
var json = JsonConvert.SerializeObject(model);
199+
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
200+
201+
var client = await this.LearningHubHttpClient.GetClientAsync();
202+
203+
var request = $"Resource/UpdateDevId";
204+
var response = await client.PutAsync(request, stringContent).ConfigureAwait(false);
205+
206+
if (response.StatusCode == HttpStatusCode.Unauthorized || response.StatusCode == HttpStatusCode.Forbidden)
207+
{
208+
throw new Exception("AccessDenied");
209+
}
210+
211+
if (!response.IsSuccessStatusCode)
212+
{
213+
throw new Exception("Update first name failed!");
214+
}
215+
}
216+
133217
/// <summary>
134218
/// The GetResourceVersionExtendedViewModelAsync.
135219
/// </summary>

0 commit comments

Comments
 (0)