Skip to content

Commit fbeaa0a

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

File tree

1 file changed

+5
-51
lines changed

1 file changed

+5
-51
lines changed

DigitalLearningSolutions.Data/DataServices/RegistrationDataService.cs

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -197,56 +197,7 @@ 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-
);
237-
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-
}
200+
250201
var adminUserId = connection.QuerySingle<int>(
251202
@"INSERT INTO AdminAccounts
252203
(
@@ -268,7 +219,10 @@ OUTPUT Inserted.ID
268219
(
269220
@userId,
270221
@centreId,
271-
@categoryId,
222+
CASE
223+
WHEN @categoryID = 0 THEN NULL
224+
ELSE @categoryID
225+
END,
272226
@isCentreAdmin,
273227
@isCentreManager,
274228
@active,

0 commit comments

Comments
 (0)