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
20 changes: 9 additions & 11 deletions LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@
return string.Empty;
}

string GetBadgeUrl()
{
if (!string.IsNullOrEmpty(Model.Catalogue.BadgeUrl))
{
return GetFileLink(Model.Catalogue.BadgeUrl);
}
return string.Empty;
}

string GetFileLink(string fileName)
{
return "/api/catalogue/download-image/" + Uri.EscapeDataString(fileName);
Expand Down Expand Up @@ -82,6 +73,9 @@
CatalogueAccessRequest = Model.CatalogueAccessRequest,
UserGroups = Model.UserGroups
};

var provider = Model.Catalogue.Providers?.FirstOrDefault();
var hasBadge = !string.IsNullOrWhiteSpace(Model.Catalogue.BadgeUrl);
}

@section styles{
Expand Down Expand Up @@ -124,9 +118,13 @@
}

<div class="catalogue-title nhsuk-u-margin-bottom-7">
@if (!string.IsNullOrEmpty(Model.Catalogue.BadgeUrl))
@if (provider != null)
{
<img src="~/images/provider-logos/@provider.Logo" alt="@provider.Name catalogue badge" class="provider-badge" />
}
else if (hasBadge)
{
<img alt="Provider's catalogue badge" src="@GetBadgeUrl()" class="catalogue-badge" />
<img src="@("/api/catalogue/download-image/" + Uri.EscapeDataString(Model.Catalogue.BadgeUrl))" alt="Provider's catalogue badgeTest" class="catalogue-card-badge" />
}

<h1 class="heading-lg title nhsuk-u-margin-bottom-0">@(ViewBag.ActiveTab == "browse" && Model.NodeDetails != null ? Model.NodeDetails.Name : Model.Catalogue.Name)</h1>
Expand Down
1 change: 1 addition & 0 deletions WebAPI/LearningHub.Nhs.Services/CatalogueService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public async Task<CatalogueViewModel> GetCatalogueAsync(string reference, int us
var bookmark = this.bookmarkRepository.GetAll().Where(b => b.NodeId == catalogue.NodeId && b.UserId == userId).FirstOrDefault();
catalogueVM.BookmarkId = bookmark?.Id;
catalogueVM.IsBookmarked = !bookmark?.Deleted ?? false;
catalogueVM.Providers = await this.providerService.GetByCatalogueVersionIdAsync(catalogueVM.Id);
return catalogueVM;
}

Expand Down
11 changes: 10 additions & 1 deletion WebAPI/LearningHub.Nhs.Services/DashboardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public async Task<DashboardMyLearningResponseViewModel> GetMyAccessLearnings(str

var cataloguesResponse = dashboardType.ToLower() == "my-catalogues" ? this.catalogueNodeVersionRepository.GetCatalogues(dashboardType, pageNumber, userId) : (TotalCount: 0, Catalogues: new List<DashboardCatalogueDto>());

var catalogueList = cataloguesResponse.Catalogues.Any() ? this.mapper.Map<List<DashboardCatalogueViewModel>>(cataloguesResponse.Catalogues) : new List<DashboardCatalogueViewModel>();
if (catalogueList.Any())
{
foreach (var catalogue in catalogueList)
{
catalogue.Providers = await this.providerService.GetByCatalogueVersionIdAsync(catalogue.NodeVersionId);
}
}

var resourceList = resources.Any() ? this.mapper.Map<List<DashboardResourceViewModel>>(resources) : new List<DashboardResourceViewModel>();
if (resourceList.Any())
{
Expand All @@ -64,7 +73,7 @@ public async Task<DashboardMyLearningResponseViewModel> GetMyAccessLearnings(str
{
Type = dashboardType,
Resources = resourceList,
Catalogues = cataloguesResponse.Catalogues.Any() ? this.mapper.Map<List<DashboardCatalogueViewModel>>(cataloguesResponse.Catalogues) : new List<DashboardCatalogueViewModel>(),
Catalogues = catalogueList,
TotalCount = dashboardType.ToLower() == "my-catalogues" ? cataloguesResponse.TotalCount : resourceCount,
CurrentPage = pageNumber,
};
Expand Down
Loading