-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNotificationsSettingViewComponent.cs
More file actions
54 lines (46 loc) · 2.02 KB
/
NotificationsSettingViewComponent.cs
File metadata and controls
54 lines (46 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
using Volo.Abp.Bundling;
using Volo.Abp.Settings;
namespace Unity.Notifications.Web.Views.Settings.NotificationsSettingGroup;
[Widget(
ScriptTypes = [typeof(NotificationsSettingScriptBundleContributor)],
StyleTypes = [typeof(NotificationsSettingStyleBundleContributor)],
AutoInitialize = true
)]
public class NotificationsSettingViewComponent(ISettingProvider settingProvider) : AbpViewComponent
{
public virtual async Task<IViewComponentResult> InvokeAsync()
{
string retryMaxSetting = await settingProvider.GetOrNullAsync(Notifications.Settings.NotificationsSettings.Mailing.EmailMaxRetryAttempts) ?? "3";
var success = int.TryParse(retryMaxSetting, out int maximumRetryAttempts);
if (!success) { maximumRetryAttempts = 3; }
var model = new NotificationsSettingViewModel
{
DefaultFromAddress = await settingProvider.GetOrNullAsync(Notifications.Settings.NotificationsSettings.Mailing.DefaultFromAddress) ?? "",
MaximumRetryAttempts = maximumRetryAttempts
};
return View("~/Views/Settings/NotificationsSettingGroup/Default.cshtml", model);
}
public class NotificationsSettingScriptBundleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context
.Files
.AddIfNotContains("/Views/Settings/NotificationsSettingGroup/Default.js");
}
}
public class NotificationsSettingStyleBundleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files
.AddIfNotContains("/Views/Settings/NotificationsSettingGroup/Default.css");
}
}
}