diff --git a/src/AdminConsole/Pages/Organization/Admins.cshtml.cs b/src/AdminConsole/Pages/Organization/Admins.cshtml.cs index ea3fcb24c..c545de868 100644 --- a/src/AdminConsole/Pages/Organization/Admins.cshtml.cs +++ b/src/AdminConsole/Pages/Organization/Admins.cshtml.cs @@ -120,16 +120,19 @@ public async Task OnPostInvite(InviteForm form) public async Task OnPostCancel(string hashedCode) { + Invites = await _invitationService.GetInvitesAsync(User.GetOrgId().Value); + + var inviteToCancel = Invites.FirstOrDefault(x => x.HashedCode == hashedCode); + await _invitationService.CancelInviteAsync(hashedCode); var performedBy = await _dataService.GetUserAsync(); - var invitationCancelled = Invites.FirstOrDefault(x => x.HashedCode == hashedCode); - if (invitationCancelled is not null) + if (inviteToCancel is not null) { _eventLogger.LogCancelAdminInviteEvent( performedBy, - invitationCancelled.ToEmail, + inviteToCancel.ToEmail, _systemClock.UtcNow.UtcDateTime ); }