diff --git a/DigitalLearningSolutions.Web/Controllers/Register/ClaimAccountController.cs b/DigitalLearningSolutions.Web/Controllers/Register/ClaimAccountController.cs index 2f25c02be0..bda98a8ad8 100644 --- a/DigitalLearningSolutions.Web/Controllers/Register/ClaimAccountController.cs +++ b/DigitalLearningSolutions.Web/Controllers/Register/ClaimAccountController.cs @@ -297,22 +297,18 @@ public IActionResult AdminAccountAlreadyExists(string email, string centreName) return RedirectToAction("AccessDenied", "LearningSolutions"); } - var adminAccounts = userService.GetUserById(loggedInUserId)!.AdminAccounts; + var userEntity = userService.GetUserById(loggedInUserId); - if (adminAccounts.Any()) + if (userEntity.DelegateAccounts!.Any(account => account.CentreId == model.CentreId)) { - return RedirectToAction( - "AdminAccountAlreadyExists", + return RedirectToAction("AccountAlreadyExists", new { email = model.Email, centreName = model.CentreName } ); } - var delegateAccounts = userService.GetUserById(loggedInUserId)!.DelegateAccounts; - - if (delegateAccounts.Any(account => account.CentreId == model.CentreId)) + if (userEntity.AdminAccounts!.Any(account => account.CentreId == model.CentreId)) { - return RedirectToAction( - "AccountAlreadyExists", + return RedirectToAction("AdminAccountAlreadyExists", new { email = model.Email, centreName = model.CentreName } ); }