DisplayNameHelper kifejlesztése
This commit is contained in:
@@ -1,21 +1,39 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class UserDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Email { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Az utónév kötelező.")]
|
||||
[DisplayName("E-mail")]
|
||||
public string Email { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Az utónév kötelező.")]
|
||||
[DisplayName("Utónév")]
|
||||
public string FirstName { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "Az vezetéknév kötelező.")]
|
||||
[DisplayName("Vezetéknév")]
|
||||
public string LastName { get; set; } = null!;
|
||||
|
||||
[Required(ErrorMessage = "A felhasználónév kötelező.")]
|
||||
[DisplayName("Felhasználó neve")]
|
||||
public string UserName { get;set; } = null!;
|
||||
|
||||
[DisplayName("Jelszó")]
|
||||
public string Password { get; set; }
|
||||
|
||||
public string JwtToken { get; set; } = null!;
|
||||
|
||||
[DisplayName("Aktív")]
|
||||
public bool Active { get; set; }
|
||||
|
||||
[DisplayName("NFC belépés")]
|
||||
public bool NFCActive { get; set; }
|
||||
|
||||
public ICollection<RoleDTO>? RoleDTO { get; set; } = new List<RoleDTO>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.Helper
|
||||
{
|
||||
public static class DisplayNameHelper
|
||||
{
|
||||
public static string GetDisplayName(string propertyName, Type modelType)
|
||||
{
|
||||
var property = modelType.GetProperty(propertyName);
|
||||
var displayNameAttribute = property?.GetCustomAttributes(typeof(DisplayNameAttribute), false)
|
||||
.FirstOrDefault() as DisplayNameAttribute;
|
||||
|
||||
return displayNameAttribute?.DisplayName ?? propertyName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user