public async Task <IActionResult> DeleteNotification([FromQuery] string notificationId) { // Validate if (string.IsNullOrEmpty(notificationId)) { return(BadRequest("Notification ID not provided")); } var notification = await subscriptionManager.GetNotificationByIdAsync(notificationId); if (notification == null) { return(NotFound()); } // Authroize var loggedInUsername = UsernameNormalizer.Normalize(HttpContext.User.Identity.Name); var authorizationResult = await authorizationModule.AuthorizeAsync( new DeleteNotificationResourceDescription(notification.Username), loggedInUsername); if (!authorizationResult.IsAuthorized) { return(StatusCode((int)HttpStatusCode.Unauthorized, "Not authorized")); } // Provide if (!await subscriptionManager.DeleteNotificationAsync(notificationId)) { return(StatusCode( (int)HttpStatusCode.InternalServerError, $"Could not delete notification with ID '{notificationId}' for user '{authorizationResult.User.UserName}'")); } return(Ok()); }