Improve EmailSettingGroupViewComponent

pull/12145/head
Engincan VESKE 4 years ago
parent 38e6adb1cb
commit f373329a93

@ -1,7 +1,7 @@
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.SettingManagement.Localization
@inject IHtmlLocalizer<AbpSettingManagementResource> L
@model Volo.Abp.SettingManagement.UpdateEmailSettingsDto
@model Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup.EmailSettingGroupViewComponent.UpdateEmailSettingsViewModel
<form id="EmailSettingsForm" method="post">
<abp-row>

@ -1,6 +1,8 @@
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Auditing;
namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup;
@ -17,7 +19,39 @@ public class EmailSettingGroupViewComponent : AbpViewComponent
public virtual async Task<IViewComponentResult> InvokeAsync()
{
var emailSettings = await EmailSettingsAppService.GetAsync();
var model = ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsDto>(emailSettings);
var model = ObjectMapper.Map<EmailSettingsDto, UpdateEmailSettingsViewModel>(emailSettings);
return View("~/Pages/SettingManagement/Components/EmailSettingGroup/Default.cshtml", model);
}
public class UpdateEmailSettingsViewModel
{
[MaxLength(256)]
public string SmtpHost { get; set; }
[Range(1, 65535)]
public int SmtpPort { get; set; }
[MaxLength(1024)]
public string SmtpUserName { get; set; }
[MaxLength(1024)]
[DataType(DataType.Password)]
[DisableAuditing]
public string SmtpPassword { get; set; }
[MaxLength(1024)]
public string SmtpDomain { get; set; }
public bool SmtpEnableSsl { get; set; }
public bool SmtpUseDefaultCredentials { get; set; }
[MaxLength(1024)]
[Required]
public string DefaultFromAddress { get; set; }
[MaxLength(1024)]
[Required]
public string DefaultFromDisplayName { get; set; }
}
}

@ -1,4 +1,5 @@
using AutoMapper;
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement.Components.EmailSettingGroup;
namespace Volo.Abp.SettingManagement.Web;
@ -6,6 +7,6 @@ public class SettingManagementWebAutoMapperProfile : Profile
{
public SettingManagementWebAutoMapperProfile()
{
CreateMap<EmailSettingsDto, UpdateEmailSettingsDto>();
CreateMap<EmailSettingsDto, EmailSettingGroupViewComponent.UpdateEmailSettingsViewModel>();
}
}
Loading…
Cancel
Save