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
4 changes: 2 additions & 2 deletions WebAPI/LearningHub.Nhs.API/Controllers/ResourceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,9 @@ public async Task<ActionResult> GetScormDetailsAsync(int resourceVersionId)
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
/// <returns>The <see cref="Task{ActionResult}"/>.</returns>
[HttpGet("GetExternalContentDetailsById/{resourceVersionId}")]
public ActionResult GetScormContentDetailsById(int resourceVersionId)
public async Task<ActionResult> GetScormContentDetailsById(int resourceVersionId)
{
return this.Ok(this.resourceService.GetExternalContentDetails(resourceVersionId, this.CurrentUserId));
return this.Ok(await this.resourceService.GetExternalContentDetails(resourceVersionId, this.CurrentUserId));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,6 @@ public interface IResourceVersionRepository : IGenericRepository<ResourceVersion
/// <param name="resourceVersionId">resourceVersionId.</param>
/// <param name="userId">userId.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
ExternalContentDetailsViewModel GetExternalContentDetails(int resourceVersionId, int userId);
Task<ExternalContentDetailsViewModel> GetExternalContentDetails(int resourceVersionId, int userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -679,15 +679,15 @@ await this.DbContext.Database.ExecuteSqlRawAsync(
/// <param name="resourceVersionId">resourceVersionId.</param>
/// <param name="userId">userId.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
public ExternalContentDetailsViewModel GetExternalContentDetails(int resourceVersionId, int userId)
public async Task<ExternalContentDetailsViewModel> GetExternalContentDetails(int resourceVersionId, int userId)
{
try
{
var param0 = new SqlParameter("@resourceVersionId", SqlDbType.Int) { Value = resourceVersionId };
var param1 = new SqlParameter("@userId", SqlDbType.Int) { Value = userId };

var externalContentDetailsViewModel = this.DbContext.ExternalContentDetailsViewModel.FromSqlRaw("[resources].[GetExternalContentDetails] @resourceVersionId, @userId", param0, param1).AsEnumerable().FirstOrDefault();

var retVal = await this.DbContext.ExternalContentDetailsViewModel.FromSqlRaw("[resources].[GetExternalContentDetails] @resourceVersionId, @userId", param0, param1).AsNoTracking().ToListAsync();
ExternalContentDetailsViewModel externalContentDetailsViewModel = retVal.AsEnumerable().FirstOrDefault();
return externalContentDetailsViewModel;
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public interface IResourceService
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
/// <param name="userId">userId.</param>
/// <returns>The <see cref="Task{ScormContentDetailsViewModel}"/>.</returns>
ExternalContentDetailsViewModel GetExternalContentDetails(int resourceVersionId, int userId);
Task<ExternalContentDetailsViewModel> GetExternalContentDetails(int resourceVersionId, int userId);

/// <summary>
/// The get image details by id async.
Expand Down
10 changes: 5 additions & 5 deletions WebAPI/LearningHub.Nhs.Services/ResourceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2793,7 +2793,7 @@ public async Task<GenericFileViewModel> GetGenericFileDetailsByIdAsync(int resou
var vm = this.mapper.Map<GenericFileViewModel>(genericFile);

// User id is used to populate a field we aren't going to use, so we can just pass in the system user id.
var externalContentDetails = this.resourceVersionRepository.GetExternalContentDetails(resourceVersionId, 4);
var externalContentDetails = await this.resourceVersionRepository.GetExternalContentDetails(resourceVersionId, 4);
if (!string.IsNullOrEmpty(externalContentDetails?.ExternalReference))
{
vm.HostedContentUrl = $"{this.settings.LearningHubContentServerUrl}/{externalContentDetails.ExternalReference}/".ToLower();
Expand All @@ -2814,7 +2814,7 @@ public async Task<HtmlResourceViewModel> GetHtmlDetailsByIdAsync(int resourceVer
var vm = this.mapper.Map<HtmlResourceViewModel>(htmlFile);

// User id is used to populate a field we aren't going to use, so we can just pass in the system user id.
var externalContentDetails = this.resourceVersionRepository.GetExternalContentDetails(resourceVersionId, 4);
var externalContentDetails = await this.resourceVersionRepository.GetExternalContentDetails(resourceVersionId, 4);
if (!string.IsNullOrEmpty(externalContentDetails?.ExternalReference))
{
vm.HostedContentUrl = $"{this.settings.LearningHubContentServerUrl}/{externalContentDetails.ExternalReference}/".ToLower();
Expand All @@ -2835,7 +2835,7 @@ public async Task<ScormViewModel> GetScormDetailsByIdAsync(int resourceVersionId
var vm = this.mapper.Map<ScormViewModel>(scorm);

// User id is used to populate a field we aren't going to use, so we can just pass in the system user id.
var externalContentDetails = this.resourceVersionRepository.GetExternalContentDetails(resourceVersionId, 4);
var externalContentDetails = await this.resourceVersionRepository.GetExternalContentDetails(resourceVersionId, 4);
if (!string.IsNullOrEmpty(externalContentDetails?.ExternalReference))
{
vm.HostedContentUrl = $"{this.settings.LearningHubContentServerUrl}/{externalContentDetails.ExternalReference}/".ToLower();
Expand All @@ -2851,9 +2851,9 @@ public async Task<ScormViewModel> GetScormDetailsByIdAsync(int resourceVersionId
/// <param name="resourceVersionId">The resourceVersionId<see cref="int"/>.</param>
/// <param name="userId">userId.</param>
/// <returns>The <see cref="Task{ExternalContentDetailsViewModel}"/>.</returns>
public ExternalContentDetailsViewModel GetExternalContentDetails(int resourceVersionId, int userId)
public async Task<ExternalContentDetailsViewModel> GetExternalContentDetails(int resourceVersionId, int userId)
{
var viewModel = this.resourceVersionRepository.GetExternalContentDetails(resourceVersionId, userId);
var viewModel = await this.resourceVersionRepository.GetExternalContentDetails(resourceVersionId, userId);
if (viewModel != null)
{
viewModel.HostedContentUrl = $"{this.settings.LearningHubContentServerUrl}/{viewModel.ExternalReference}/".ToLower();
Expand Down