mirror of https://github.com/abpframework/abp.git
52 changed files with 521 additions and 72 deletions
@ -0,0 +1,25 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.Domain.Values; |
||||
|
|
||||
|
public class EmailAddress : ValueObject |
||||
|
{ |
||||
|
public string Email { get; } |
||||
|
|
||||
|
private EmailAddress() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public EmailAddress(string email) |
||||
|
{ |
||||
|
Email = email; |
||||
|
} |
||||
|
|
||||
|
protected override IEnumerable<object> GetAtomicValues() |
||||
|
{ |
||||
|
if (Email != null) |
||||
|
{ |
||||
|
yield return Email; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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,31 @@ |
|||||
|
@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> |
||||
|
<abp-button data-bs-dismiss="modal" button-type="Secondary">@L["Cancel"]</abp-button> |
||||
|
<abp-button button-type="Primary" type="submit"> |
||||
|
<i class="fa fa-send"></i> @L["Send"] |
||||
|
</abp-button> |
||||
|
</abp-modal-footer> |
||||
|
|
||||
|
</abp-modal> |
||||
|
</form> |
||||
@ -0,0 +1,59 @@ |
|||||
|
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] |
||||
|
public string SenderEmailAddress { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
public string TargetEmailAddress { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
public string Subject { get; set; } |
||||
|
|
||||
|
public string Body { get; set; } |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue