mirror of https://github.com/abpframework/abp.git
21 changed files with 422 additions and 21 deletions
@ -0,0 +1,17 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Volo.Abp.SettingManagement; |
|||
|
|||
public class SendTestEmailInput |
|||
{ |
|||
[Required] |
|||
public string SenderEmailAddress { get; set; } |
|||
|
|||
[Required] |
|||
public string TargetEmailAddress { get; set; } |
|||
|
|||
[Required] |
|||
public string Subject { get; set; } |
|||
|
|||
public string Body { get; set; } |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
@page |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Microsoft.AspNetCore.Mvc.TagHelpers |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|||
@using Volo.Abp.SettingManagement.Localization |
|||
@using Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup |
|||
@model SendTestEmailModal |
|||
@inject IHtmlLocalizer<AbpSettingManagementResource> L |
|||
@{ |
|||
Layout = null; |
|||
} |
|||
|
|||
<form asp-page="/SettingManagement/Components/EmailSettingGroup/SendTestEmailModal"> |
|||
<abp-modal> |
|||
<abp-modal-header title="@L["SendTestEmail"].Value"></abp-modal-header> |
|||
<abp-modal-body> |
|||
<abp-input asp-for="Input.SenderEmailAddress" /> |
|||
<abp-input asp-for="Input.TargetEmailAddress" /> |
|||
<abp-input asp-for="Input.Subject" /> |
|||
<abp-input asp-for="Input.Body" /> |
|||
</abp-modal-body> |
|||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
|||
</abp-modal> |
|||
</form> |
|||
@ -0,0 +1,63 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
|||
using Volo.Abp.SettingManagement.Localization; |
|||
|
|||
namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup; |
|||
|
|||
[Authorize(SettingManagementPermissions.EmailingTest)] |
|||
public class SendTestEmailModal : AbpPageModel |
|||
{ |
|||
[BindProperty] |
|||
public SendTestEmailViewModel Input { get; set; } |
|||
|
|||
protected IEmailSettingsAppService EmailSettingsAppService { get; } |
|||
|
|||
public SendTestEmailModal(IEmailSettingsAppService emailSettingsAppService) |
|||
{ |
|||
LocalizationResourceType = typeof(AbpSettingManagementResource); |
|||
EmailSettingsAppService = emailSettingsAppService; |
|||
} |
|||
|
|||
public async Task OnGetAsync() |
|||
{ |
|||
var emailSettings = await EmailSettingsAppService.GetAsync(); |
|||
Input = new SendTestEmailViewModel |
|||
{ |
|||
SenderEmailAddress = emailSettings.DefaultFromAddress, |
|||
TargetEmailAddress = CurrentUser.Email, |
|||
Subject = L["TestEmailSubject", new Random().Next(1000, 9999)], |
|||
Body = L["TestEmailBody"] |
|||
}; |
|||
} |
|||
|
|||
public async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
ValidateModel(); |
|||
|
|||
await EmailSettingsAppService.SendTestEmailAsync(ObjectMapper.Map<SendTestEmailViewModel, SendTestEmailInput>(Input)); |
|||
|
|||
return NoContent(); |
|||
} |
|||
|
|||
public class SendTestEmailViewModel |
|||
{ |
|||
[Required] |
|||
[Display(Name = "SenderEmailAddress")] |
|||
public string SenderEmailAddress { get; set; } |
|||
|
|||
[Required] |
|||
[Display(Name = "TargetEmailAddress")] |
|||
public string TargetEmailAddress { get; set; } |
|||
|
|||
[Required] |
|||
[Display(Name = "Subject")] |
|||
public string Subject { get; set; } |
|||
|
|||
[Display(Name = "Body")] |
|||
public string Body { get; set; } |
|||
} |
|||
} |
|||
Loading…
Reference in new issue