Skip to content

Commit 3c09df3

Browse files
TD-4889 Resolving internal server error when nominating delegate to supervisor
1 parent 49d6df1 commit 3c09df3

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

DigitalLearningSolutions.Data/DataServices/RegistrationDataService.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,56 @@ public int RegisterAdmin(
197197
isSupervisor = registrationModel.IsSupervisor,
198198
isNominatedSupervisor = registrationModel.IsNominatedSupervisor,
199199
};
200+
if (registrationModel.CategoryId == 0)
201+
{
202+
var adminUserIdwithCategoryIdIsNull = connection.QuerySingle<int>(
203+
@"INSERT INTO AdminAccounts
204+
(
205+
UserID,
206+
CentreID,
207+
CategoryID,
208+
IsCentreAdmin,
209+
IsCentreManager,
210+
Active,
211+
IsContentCreator,
212+
IsContentManager,
213+
ImportOnly,
214+
IsTrainer,
215+
IsSupervisor,
216+
IsNominatedSupervisor
217+
)
218+
OUTPUT Inserted.ID
219+
VALUES
220+
(
221+
@userId,
222+
@centreId,
223+
NULL,
224+
@isCentreAdmin,
225+
@isCentreManager,
226+
@active,
227+
@isContentCreator,
228+
@isContentManager,
229+
@importOnly,
230+
@isTrainer,
231+
@isSupervisor,
232+
@isNominatedSupervisor
233+
)",
234+
adminValues,
235+
transaction
236+
);
200237

238+
connection.Execute(
239+
@"INSERT INTO NotificationUsers (NotificationId, AdminUserId)
240+
SELECT N.NotificationId, @adminUserIdwithCategoryIdIsNull
241+
FROM Notifications N INNER JOIN NotificationRoles NR
242+
ON N.NotificationID = NR.NotificationID
243+
WHERE RoleID IN @roles AND AutoOptIn = 1",
244+
new { adminUserIdwithCategoryIdIsNull, roles = registrationModel.GetNotificationRoles() },
245+
transaction
246+
);
247+
transaction.Commit();
248+
return adminUserIdwithCategoryIdIsNull;
249+
}
201250
var adminUserId = connection.QuerySingle<int>(
202251
@"INSERT INTO AdminAccounts
203252
(

DigitalLearningSolutions.Web/Controllers/SupervisorController/Supervisor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ public IActionResult ConfirmNominateSupervisor(SupervisorDelegateViewModel super
13141314
supervisorDelegateDetail.DelegateUserID,
13151315
(int)User.GetCentreId()
13161316
);
1317-
supervisorDelegate.SelfAssessmentCategory = supervisorDelegate.SelfAssessmentCategory == 0 ? adminUser.CategoryId.Value : supervisorDelegate.SelfAssessmentCategory;
1317+
supervisorDelegate.SelfAssessmentCategory = supervisorDelegate.SelfAssessmentCategory == 0 ? (adminUser.CategoryId.HasValue ? adminUser.CategoryId.Value : 0) : supervisorDelegate.SelfAssessmentCategory;
13181318
var centreName = adminUser.CentreName;
13191319

13201320
var adminRoles = new AdminRoles(false, false, true, false, false, false, false, false);

0 commit comments

Comments
 (0)