using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Abp; using Abp.Extensions; using Abp.Notifications; using Abp.Timing; using Abp.Web.Security.AntiForgery; using VberAdmin.Controllers; namespace VberAdmin.Web.Host.Controllers; public class HomeController : VberAdminControllerBase { private readonly INotificationPublisher _notificationPublisher; public HomeController(INotificationPublisher notificationPublisher) { _notificationPublisher = notificationPublisher; } public IActionResult Index() { return Redirect("/doc"); } /// /// This is a demo code to demonstrate sending notification to default tenant admin and host admin uers. /// Don't use this code in production !!! /// /// /// public async Task TestNotification(string message = "") { if (message.IsNullOrEmpty()) { message = "This is a test notification, created at " + Clock.Now; } var defaultTenantAdmin = new UserIdentifier(1, 2); var hostAdmin = new UserIdentifier(null, 1); await _notificationPublisher.PublishAsync( "App.SimpleMessage", new MessageNotificationData(message), severity: NotificationSeverity.Info, userIds: new[] { defaultTenantAdmin, hostAdmin } ); return Content("Sent notification: " + message); } }