Try to use attributes for enum to string conversion

This commit is contained in:
2025-11-05 11:34:38 +09:00
parent 3d3ee858c4
commit 0169e5724d
2 changed files with 6 additions and 17 deletions

View File

@ -40,11 +40,7 @@
</Template> </Template>
<Columns> <Columns>
<RadzenDataGridColumn TItem="Campaign" Property="Id" Title="ID" SortOrder="SortOrder.Descending" Resizable="false" Width="100px" MaxWidth="100px" /> <RadzenDataGridColumn TItem="Campaign" Property="Id" Title="ID" SortOrder="SortOrder.Descending" Resizable="false" Width="100px" MaxWidth="100px" />
<RadzenDataGridColumn TItem="Campaign" Property="Type" Title="Тип кампании"> <RadzenDataGridColumn TItem="Campaign" Property="Type" Title="Тип кампании" />
<Template Context="campaign">
@CampaignTypeToString(campaign.Type)
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn TItem="Campaign" Property="CreatedAt" Title="Дата создания" Resizable="false" Width="150px" MaxWidth="150px" /> <RadzenDataGridColumn TItem="Campaign" Property="CreatedAt" Title="Дата создания" Resizable="false" Width="150px" MaxWidth="150px" />
<RadzenDataGridColumn TItem="Campaign" Property="StartedAt" Title="Дата начала" Resizable="false" Width="150px" MaxWidth="150px" /> <RadzenDataGridColumn TItem="Campaign" Property="StartedAt" Title="Дата начала" Resizable="false" Width="150px" MaxWidth="150px" />
<RadzenDataGridColumn TItem="Campaign" Property="StartedAt" Title="Дата окончания" Resizable="false" Width="150px" MaxWidth="150px" /> <RadzenDataGridColumn TItem="Campaign" Property="StartedAt" Title="Дата окончания" Resizable="false" Width="150px" MaxWidth="150px" />
@ -127,17 +123,6 @@
}); });
} }
string CampaignTypeToString(Campaign.CampaignType campaignType)
{
return campaignType switch
{
Campaign.CampaignType.ExportPrivateRegistryElements_15_7_0_1 => "Экспорт частных справочников",
Campaign.CampaignType.ExportCommonRegistryElements_15_7_0_1 => "Экспорт общих справочников",
_ => "???"
};
}
public void Dispose() public void Dispose()
{ {
CampaignManagementState.OnCampaignCreated -= OnCampaignCreated; CampaignManagementState.OnCampaignCreated -= OnCampaignCreated;

View File

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Hcs.WebApp.Data.Hcs namespace Hcs.WebApp.Data.Hcs
{ {
@ -6,7 +7,10 @@ namespace Hcs.WebApp.Data.Hcs
{ {
public enum CampaignType public enum CampaignType
{ {
[Display(Description = "Экспорт общих справочников")]
ExportCommonRegistryElements_15_7_0_1, ExportCommonRegistryElements_15_7_0_1,
[Display(Description = "Экспорт частных справочников")]
ExportPrivateRegistryElements_15_7_0_1 ExportPrivateRegistryElements_15_7_0_1
} }