Skip to content

Commit 66d8aed

Browse files
committed
TD-3713- Update LastAccessed Date For AdminAccounts And DelegateAccounts
1 parent b5cf544 commit 66d8aed

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

DigitalLearningSolutions.Data/DataServices/LoginDataService.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
public interface ILoginDataService
77
{
88
void UpdateLastAccessedForUsersTable(int Id);
9+
10+
void UpdateLastAccessedForDelegatesAccountsTable(int Id);
11+
12+
void UpdateLastAccessedForAdminAccountsTable(int Id);
913
}
1014

1115
public class LoginDataService : ILoginDataService
@@ -29,5 +33,31 @@ public void UpdateLastAccessedForUsersTable(int Id)
2933
}
3034
);
3135
}
36+
37+
public void UpdateLastAccessedForDelegatesAccountsTable(int Id)
38+
{
39+
connection.Execute(
40+
@"UPDATE DelegateAccounts SET
41+
LastAccessed = GetUtcDate()
42+
WHERE ID = @Id",
43+
new
44+
{
45+
Id
46+
}
47+
);
48+
}
49+
50+
public void UpdateLastAccessedForAdminAccountsTable(int Id)
51+
{
52+
connection.Execute(
53+
@"UPDATE AdminAccounts SET
54+
LastAccessed = GetUtcDate()
55+
WHERE ID = @Id",
56+
new
57+
{
58+
Id
59+
}
60+
);
61+
}
3262
}
3363
}

DigitalLearningSolutions.Web/Controllers/LoginController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,13 @@ int centreIdToLogInto
226226
IsPersistent = rememberMe,
227227
IssuedUtc = clockUtility.UtcNow,
228228
};
229+
var centreAccountSet = userEntity?.GetCentreAccountSet(centreIdToLogInto);
230+
loginService.UpdateLastAccessedForDelegatesAccountsTable(centreAccountSet.DelegateAccount.Id);
229231

230-
var adminAccount = userEntity!.GetCentreAccountSet(centreIdToLogInto)?.AdminAccount;
231-
232+
var adminAccount = centreAccountSet?.AdminAccount;
232233
if (adminAccount?.Active == true)
233234
{
235+
loginService.UpdateLastAccessedForAdminAccountsTable(adminAccount.Id);
234236
sessionService.StartAdminSession(adminAccount.Id);
235237
}
236238

DigitalLearningSolutions.Web/Services/LoginService.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ List<int> idsOfCentresWithUnverifiedEmails
3232

3333
void UpdateLastAccessedForUsersTable(int Id);
3434

35+
void UpdateLastAccessedForDelegatesAccountsTable(int Id);
36+
37+
void UpdateLastAccessedForAdminAccountsTable(int Id);
38+
3539
Task<string> HandleLoginResult(
3640
LoginResult loginResult,
3741
TicketReceivedContext context,
@@ -59,6 +63,16 @@ public void UpdateLastAccessedForUsersTable(int Id)
5963
loginDataService.UpdateLastAccessedForUsersTable(Id);
6064
}
6165

66+
public void UpdateLastAccessedForDelegatesAccountsTable(int Id)
67+
{
68+
loginDataService.UpdateLastAccessedForDelegatesAccountsTable(Id);
69+
}
70+
71+
public void UpdateLastAccessedForAdminAccountsTable(int Id)
72+
{
73+
loginDataService.UpdateLastAccessedForAdminAccountsTable(Id);
74+
}
75+
6276
public LoginResult AttemptLogin(string username, string password)
6377
{
6478
var userEntity = userService.GetUserByUsername(username);

0 commit comments

Comments
 (0)