mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.2 KiB
60 lines
2.2 KiB
using System;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.AspNetCore.Components.Notifications;
|
|
using Volo.Abp.DependencyInjection;
|
|
|
|
namespace Volo.Abp.BlazoriseUI;
|
|
|
|
[Dependency(ReplaceServices = true)]
|
|
public class BlazoriseUiNotificationService : IUiNotificationService, IScopedDependency
|
|
{
|
|
/// <summary>
|
|
/// An event raised after the notification is received.
|
|
/// </summary>
|
|
public event EventHandler<UiNotificationEventArgs>? NotificationReceived;
|
|
|
|
public Task Info(string message, string? title = null, Action<UiNotificationOptions>? options = null)
|
|
{
|
|
var uiNotificationOptions = CreateDefaultOptions();
|
|
options?.Invoke(uiNotificationOptions);
|
|
|
|
NotificationReceived?.Invoke(this, new UiNotificationEventArgs(UiNotificationType.Info, message, title, uiNotificationOptions));
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task Success(string message, string? title = null, Action<UiNotificationOptions>? options = null)
|
|
{
|
|
var uiNotificationOptions = CreateDefaultOptions();
|
|
options?.Invoke(uiNotificationOptions);
|
|
|
|
NotificationReceived?.Invoke(this, new UiNotificationEventArgs(UiNotificationType.Success, message, title, uiNotificationOptions));
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task Warn(string message, string? title = null, Action<UiNotificationOptions>? options = null)
|
|
{
|
|
var uiNotificationOptions = CreateDefaultOptions();
|
|
options?.Invoke(uiNotificationOptions);
|
|
|
|
NotificationReceived?.Invoke(this, new UiNotificationEventArgs(UiNotificationType.Warning, message, title, uiNotificationOptions));
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task Error(string message, string? title = null, Action<UiNotificationOptions>? options = null)
|
|
{
|
|
var uiNotificationOptions = CreateDefaultOptions();
|
|
options?.Invoke(uiNotificationOptions);
|
|
|
|
NotificationReceived?.Invoke(this, new UiNotificationEventArgs(UiNotificationType.Error, message, title, uiNotificationOptions));
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
protected virtual UiNotificationOptions CreateDefaultOptions()
|
|
{
|
|
return new UiNotificationOptions();
|
|
}
|
|
}
|
|
|