| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 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");
- }
- /// <summary>
- /// This is a demo code to demonstrate sending notification to default tenant admin and host admin uers.
- /// Don't use this code in production !!!
- /// </summary>
- /// <param name="message"></param>
- /// <returns></returns>
- public async Task<ActionResult> 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);
- }
- }
|