Skip to content

Commit 054bf24

Browse files
committed
conflicts resloved
2 parents 79501e7 + 8d75895 commit 054bf24

File tree

122 files changed

+3815
-1314
lines changed

Some content is hidden

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

122 files changed

+3815
-1314
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ obj
4848
/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Staging.Database/LearningHub.Nhs.Migration.Staging.Database.dbmdl
4949
/WebAPI/MigrationTool/LearningHub.Nhs.Migration.Staging.Database/LearningHub.Nhs.Migration.Staging.Database.jfm
5050
/LearningHub.Nhs.WebUI.AutomatedUiTests/appsettings.Development.json
51+
/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.Development.json
52+
/OpenAPI/LearningHub.Nhs.OpenApi/web.config
53+
/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj.user
54+
/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj.user

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/Controllers/UserGroupController.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ public async Task<IActionResult> AddUsersToUserGroup(int userGroupId, string use
257257
var vr = await this.userGroupService.AddUsersToUserGroup(userGroupId, userIdList);
258258
if (vr.IsValid)
259259
{
260+
this.ClearUserCachedPermissions(userIdList);
260261
return this.Json(new
261262
{
262263
success = true,
@@ -527,5 +528,16 @@ public async Task<IActionResult> UserGroupCatalogues(int id)
527528

528529
return this.PartialView("_UserGroupCatalogues", catalogues);
529530
}
531+
532+
private void ClearUserCachedPermissions(string userIdList)
533+
{
534+
if (!string.IsNullOrWhiteSpace(userIdList))
535+
{
536+
foreach (var userId in userIdList.Split(","))
537+
{
538+
_ = Task.Run(async () => { await this.userService.ClearUserCachedPermissions(int.Parse(userId)); });
539+
}
540+
}
541+
}
530542
}
531543
}

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.33" />
92+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.41" />
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>

AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/Edit.cshtml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@
162162
<span class="input-validation-error keyword-maxlength" style="display: none;">The maximum length is 50 characters.</span>
163163
</div>
164164
</div>
165+
<div class="row">
166+
<div class="col-12">
167+
<span id="keyword-error-span" class="field-validation-error" style="display: none;"></span>
168+
</div>
169+
</div>
165170

166171
</div>
167172
<div class="col-12">
@@ -341,6 +346,9 @@
341346
} else {
342347
$('#add-keyword').removeAttr('disabled');
343348
}
349+
350+
$('#keyword-error-span').hide();
351+
$('#keyword-error-span').html('');
344352
});
345353
346354
$('#add-keyword').on('click', function () {
@@ -352,9 +360,11 @@
352360
353361
// Split the input value by commas and trim each keyword
354362
var values = value.split(',').map(function (item) {
355-
return item.trim();
363+
return item.trim().toLowerCase();
356364
});
357365
366+
var duplicateKeywords = [];
367+
$('#keyword-error-span').hide();
358368
values.forEach(function (value) {
359369
if (value && keywords.indexOf(value) === -1) {
360370
keywords.push(value);
@@ -368,9 +378,15 @@
368378
$(x).attr('name', "Keywords[" + i + "]");
369379
});
370380
}
381+
else
382+
{
383+
duplicateKeywords.push(value);
384+
$('#keyword-error-span').show();
385+
$('#keyword-error-span').html('The keyword(s) have already been added : ' + duplicateKeywords.join(', '))
386+
}
371387
});
372388
373-
$keywordInput.val("");
389+
$keywordInput.val("");
374390
if (keywords.length > 4) {
375391
$('#add-keyword').attr('disabled', 'disabled');
376392
$('#add-keyword-input').attr('disabled', 'disabled');
@@ -441,4 +457,4 @@
441457
442458
</script>
443459
<script src="~/js/imageInput.js"></script>
444-
}
460+
}

0 commit comments

Comments
 (0)