Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@
/// The Details.
/// </summary>
/// <param name="id">The id<see cref="int"/>.</param>
/// <param name="activeTab">The activeTab<see cref="string"/>.</param>
/// <param name="status">The status<see cref="string"/>.</param>
/// <returns>The <see cref="Task{IActionResult}"/>.</returns>
[HttpGet]
public async Task<IActionResult> Details(int id)
public async Task<IActionResult> Details(int id, string activeTab = "details", string status = "")
{
var resource = await this.resourceService.GetResourceVersionExtendedViewModelAsync(id);
this.ViewBag.ActiveTab = activeTab;
this.ViewBag.Status = status;
return this.View(resource);
}

Expand Down Expand Up @@ -138,6 +142,41 @@
return this.PartialView("_ValidationResults", vm);
}

/// <summary>
/// The GetDevIdDetails.
/// </summary>
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
/// <returns>The <see cref="Task{IActionResult}"/>.</returns>
[HttpPost]
public async Task<IActionResult> GetDevIdDetails(int resourceVersionId)
{
var vm = await this.resourceService.GetResourceVersionDevIdDetailsAsync(resourceVersionId);

return this.PartialView("_DevIdDetails", vm);
}

/// <summary>
/// The update the dev Id details.
/// </summary>
/// <param name="model">The model.</param>
/// <returns>The <see cref="Task{IActionResult}"/>.</returns>
[HttpPost]
public async Task<IActionResult> UpdateDevIdDetails(ResourceVersionDevIdViewModel model)

Check failure on line 164 in AdminUI/LearningHub.Nhs.AdminUI/Controllers/ResourceController.cs

View workflow job for this annotation

GitHub Actions / Build and test

The type or namespace name 'ResourceVersionDevIdViewModel' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 164 in AdminUI/LearningHub.Nhs.AdminUI/Controllers/ResourceController.cs

View workflow job for this annotation

GitHub Actions / Build and test

The type or namespace name 'ResourceVersionDevIdViewModel' could not be found (are you missing a using directive or an assembly reference?)
{
var message = string.Empty;
if (await this.resourceService.DoesDevIdExistsAsync(model.DevId))
{
message = "Duplicate";
}
else
{
await this.resourceService.UpdateDevIdDetailsAsync(model);
message = "Success";
}

return this.RedirectToAction("Details", new { id = model.ResourceVersionId, activeTab = "devId", status = message });
}

/// <summary>
/// The Index.
/// </summary>
Expand Down
23 changes: 22 additions & 1 deletion AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,30 @@
/// The GetResourceVersionValidationResultAsync.
/// </summary>
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
/// <returns>The <see cref="Task{ResourceVersionEventViewModel}}"/>.</returns>
/// <returns>The <see cref="Task{ResourceVersionValidationResultViewModel}}"/>.</returns>

Check warning on line 35 in AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

XML comment has syntactically incorrect cref attribute 'Task{ResourceVersionValidationResultViewModel}}'
Task<ResourceVersionValidationResultViewModel> GetResourceVersionValidationResultAsync(int resourceVersionId);

/// <summary>
/// The GetResourceVersionDevIdDetailsAsync.
/// </summary>
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
/// <returns>The <see cref="Task{ResourceVersionDevIdViewModel}}"/>.</returns>

Check warning on line 42 in AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

XML comment has syntactically incorrect cref attribute 'Task{ResourceVersionDevIdViewModel}}'
Task<ResourceVersionDevIdViewModel> GetResourceVersionDevIdDetailsAsync(int resourceVersionId);

Check failure on line 43 in AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

The type or namespace name 'ResourceVersionDevIdViewModel' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 43 in AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

The type or namespace name 'ResourceVersionDevIdViewModel' could not be found (are you missing a using directive or an assembly reference?)

/// <summary>
/// Check dev id already exist against a resource.
/// </summary>
/// <param name="devId">string devId.</param>
/// <returns>The <see cref="Task{bool}"/>.</returns>

Check warning on line 49 in AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

XML comment has syntactically incorrect cref attribute 'Task{bool}'

Check warning on line 49 in AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

Type parameter declaration must be an identifier not a type. See also error CS0081.
Task<bool> DoesDevIdExistsAsync(string devId);

/// <summary>
/// To update dev id details for a resource.
/// </summary>
/// <param name="model">the ResourceVersionDevIdViewModel.</param>
/// <returns>The <see cref="Task{ResourceVersionDevIdViewModel}}"/>.</returns>
Task UpdateDevIdDetailsAsync(ResourceVersionDevIdViewModel model);

Check failure on line 57 in AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

The type or namespace name 'ResourceVersionDevIdViewModel' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 57 in AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

The type or namespace name 'ResourceVersionDevIdViewModel' could not be found (are you missing a using directive or an assembly reference?)

/// <summary>
/// The GetResourceVersionExtendedViewModelAsync.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<PackageReference Include="HtmlSanitizer" Version="6.0.453" />
<PackageReference Include="IdentityModel" Version="4.4.0" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.40" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.41" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
Expand Down
84 changes: 84 additions & 0 deletions AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -105,7 +106,7 @@
/// The GetResourceVersionValidationResultAsync.
/// </summary>
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
/// <returns>The <see cref="Task{List{ResourceVersionValidationResultViewModel}}"/>.</returns>

Check warning on line 109 in AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

XML comment has syntactically incorrect cref attribute 'Task{List{ResourceVersionValidationResultViewModel}}'

Check warning on line 109 in AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

Type parameter declaration must be an identifier not a type. See also error CS0081.
public async Task<ResourceVersionValidationResultViewModel> GetResourceVersionValidationResultAsync(int resourceVersionId)
{
ResourceVersionValidationResultViewModel viewmodel = null;
Expand All @@ -130,6 +131,89 @@
return viewmodel;
}

/// <summary>
/// The GetResourceVersionDevIdDetailsAsync.
/// </summary>
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
/// <returns>The <see cref="List{ResourceVersionDevIdViewModel}"/>.</returns>
public async Task<ResourceVersionDevIdViewModel> GetResourceVersionDevIdDetailsAsync(int resourceVersionId)

Check failure on line 139 in AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

The type or namespace name 'ResourceVersionDevIdViewModel' could not be found (are you missing a using directive or an assembly reference?)
{
ResourceVersionDevIdViewModel viewmodel = null;

var client = await this.LearningHubHttpClient.GetClientAsync();

var request = $"Resource/GetResourceVersionDevIdDetails/{resourceVersionId.ToString()}";
var response = await client.GetAsync(request).ConfigureAwait(false);

if (response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsStringAsync().Result;
viewmodel = JsonConvert.DeserializeObject<ResourceVersionDevIdViewModel>(result);
}
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
||
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
{
throw new Exception("AccessDenied");
}

return viewmodel;
}

/// <summary>
/// The GetResourceVersionDevIdDetailsAsync.
/// </summary>
/// <param name="devId">The devId<see cref="string"/>.</param>
/// <returns>The <see cref="List{ResourceVersionDevIdViewModel}"/>.</returns>
public async Task<bool> DoesDevIdExistsAsync(string devId)
{
var client = await this.LearningHubHttpClient.GetClientAsync();

var request = $"Resource/DoesDevIdExists/{devId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
var doesDevIdExist = false;
if (response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsStringAsync().Result;
doesDevIdExist = JsonConvert.DeserializeObject<bool>(result);
}
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
||
response.StatusCode == System.Net.HttpStatusCode.Forbidden)
{
throw new Exception("AccessDenied");
}

return doesDevIdExist;
}

/// <summary>
/// Update dev id details for a resource.
/// </summary>
/// <param name="model">The model.</param>
/// <returns>The <see cref="List{ResourceVersionDevIdViewModel}"/>.</returns>
/// <exception cref="Exception">the exception.</exception>
public async Task UpdateDevIdDetailsAsync(ResourceVersionDevIdViewModel model)

Check failure on line 196 in AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs

View workflow job for this annotation

GitHub Actions / Build and test

The type or namespace name 'ResourceVersionDevIdViewModel' could not be found (are you missing a using directive or an assembly reference?)
{
var json = JsonConvert.SerializeObject(model);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

var client = await this.LearningHubHttpClient.GetClientAsync();

var request = $"Resource/UpdateDevId";
var response = await client.PutAsync(request, stringContent).ConfigureAwait(false);

if (response.StatusCode == HttpStatusCode.Unauthorized || response.StatusCode == HttpStatusCode.Forbidden)
{
throw new Exception("AccessDenied");
}

if (!response.IsSuccessStatusCode)
{
throw new Exception("Update first name failed!");
}
}

/// <summary>
/// The GetResourceVersionExtendedViewModelAsync.
/// </summary>
Expand Down
Loading
Loading