Skip to content

Commit 66aace7

Browse files
authored
Merge pull request #219 from TechnologyEnhancedLearning/Develop/Fixes/TD-3950
TD-3950 bookmark partial view error bugfix
2 parents 7aacda4 + ae37ec7 commit 66aace7

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

LearningHub.Nhs.WebUI/Controllers/HomeController.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,29 @@ public async Task<IActionResult> LoadPage(string dashBoardTray = "my-learning",
246246
Catalogues = new Nhs.Models.Dashboard.DashboardCatalogueResponseViewModel { Type = catalogueDashBoard },
247247
};
248248

249-
switch (dashBoardTray)
249+
bool isAjax = this.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest";
250+
251+
if (isAjax)
250252
{
251-
case "my-learning":
252-
model.MyLearnings = await this.dashboardService.GetMyAccessLearningsAsync(myLearningDashBoard, pageNumber);
253-
return this.PartialView("_MyAccessedLearningTray", model);
254-
case "resources":
255-
model.Resources = await this.dashboardService.GetResourcesAsync(resourceDashBoard, pageNumber);
256-
return this.PartialView("_ResourceTray", model);
257-
case "catalogues":
258-
model.Catalogues = await this.dashboardService.GetCataloguesAsync(catalogueDashBoard, pageNumber);
259-
return this.PartialView("_CatalogueTray", model);
253+
switch (dashBoardTray)
254+
{
255+
case "my-learning":
256+
model.MyLearnings = await this.dashboardService.GetMyAccessLearningsAsync(myLearningDashBoard, pageNumber);
257+
return this.PartialView("_MyAccessedLearningTray", model);
258+
case "resources":
259+
model.Resources = await this.dashboardService.GetResourcesAsync(resourceDashBoard, pageNumber);
260+
return this.PartialView("_ResourceTray", model);
261+
case "catalogues":
262+
model.Catalogues = await this.dashboardService.GetCataloguesAsync(catalogueDashBoard, pageNumber);
263+
return this.PartialView("_CatalogueTray", model);
264+
}
265+
}
266+
else
267+
{
268+
model.MyLearnings = await this.dashboardService.GetMyAccessLearningsAsync(myLearningDashBoard, dashBoardTray == "my-learning" ? pageNumber : 1);
269+
model.Resources = await this.dashboardService.GetResourcesAsync(resourceDashBoard, dashBoardTray == "resources" ? pageNumber : 1);
270+
model.Catalogues = await this.dashboardService.GetCataloguesAsync(catalogueDashBoard, dashBoardTray == "catalogues" ? pageNumber : 1);
271+
return this.View("Dashboard", model);
260272
}
261273
}
262274

0 commit comments

Comments
 (0)