public async Task RejectTransferAndDismissAlertAsync() { var user = await _referenceDataRepository.GetUserByUsernameAsync(User.FindFirstValue(ClaimTypes.Upn)); var transferRejectedAlert = new TransferRejectedAlert { CaseManagerUsername = Notification.HospitalDetails.CaseManagerUsername, NotificationId = NotificationId, RejectionReason = DeclineTransferReason ?? "No reason was given when declining this transfer.", DecliningUserAndTbServiceString = $"{user.DisplayName}, {TransferAlert.TbServiceName}", TbServiceCode = Notification.HospitalDetails.TBServiceCode }; // Dismiss any existing transfer rejected alert so that the new one can be created var pendingTransferRejectedAlert = await _alertRepository.GetOpenAlertByNotificationId <TransferRejectedAlert>(NotificationId); if (pendingTransferRejectedAlert != null) { await _alertService.DismissAlertAsync(pendingTransferRejectedAlert.AlertId, User.FindFirstValue(ClaimTypes.Upn)); } await _alertService.AddUniqueOpenAlertAsync(transferRejectedAlert); await _alertService.DismissAlertAsync(TransferAlert.AlertId, User.FindFirstValue(ClaimTypes.Upn)); }
public async Task <IActionResult> OnPostAsync() { TransferRejectedAlert = await _alertRepository.GetOpenAlertByNotificationId <TransferRejectedAlert>(NotificationId); await _alertService.DismissAlertAsync(TransferRejectedAlert.AlertId, User.Username()); return(RedirectToPage("/Notifications/Overview", new { NotificationId })); }
public async Task <IActionResult> OnGetAsync() { Notification = await NotificationRepository.GetNotificationAsync(NotificationId); TransferRejectedAlert = await _alertRepository.GetOpenAlertByNotificationId <TransferRejectedAlert>(NotificationId); await AuthorizeAndSetBannerAsync(); // Check edit permission of user and redirect if they don't have permission or the alert does not exist var(permissionLevel, _) = await _authorizationService.GetPermissionLevelAsync(User, Notification); if (permissionLevel != PermissionLevel.Edit || TransferRejectedAlert == null) { return(RedirectToPage("/Notifications/Overview", new { NotificationId })); } return(Page()); }
public async Task RejectTransferAndDismissAlertAsync() { var user = await _referenceDataRepository.GetUserByUsernameAsync(User.Username()); var transferRejectedAlert = new TransferRejectedAlert { NotificationId = NotificationId, RejectionReason = TransferRequest.DeclineTransferReason ?? "No reason was given when declining this transfer.", DecliningUserAndTbServiceString = $"{user.DisplayName}, {TransferRequest.TransferAlert.TbService.Name}" }; // Dismiss any existing transfer rejected alert so that the new one can be created var pendingTransferRejectedAlert = await _alertRepository.GetOpenAlertByNotificationId <TransferRejectedAlert>(NotificationId); if (pendingTransferRejectedAlert != null) { await _alertService.DismissAlertAsync(pendingTransferRejectedAlert.AlertId, User.Username()); } await _alertService.AddUniqueOpenAlertAsync(transferRejectedAlert); await _alertService.DismissAlertAsync(TransferRequest.TransferAlert.AlertId, User.Username()); }