galaeth-draft/Galaeth.Services/Profiles/AutomapperProfile.cs
2024-11-17 09:31:01 +00:00

24 lines
737 B
C#

using AutoMapper;
using Galaeth.Core.Dtos;
using Galaeth.Core.Entities;
using Galaeth.Services.Dtos;
namespace Galaeth.Services.Profiles;
/// <summary>
/// Profile for AutoMapper.
/// </summary>
public class AutomapperProfile : Profile
{
/// <summary>
/// Initializes a new instance of the <see cref="AutomapperProfile"/> class.
/// </summary>
public AutomapperProfile()
{
CreateMap<User, UserDto>()
.ForMember(dest => dest.RegistrationDate, opt => opt.MapFrom(src => src.CreatedAt))
.ForMember(dest => dest.RegistrationDateTicks, opt => opt.MapFrom(src => src.CreatedAt.Ticks))
.ForMember(dest => dest.RoleTitle, opt => opt.MapFrom(src => src.Role.ToString()));
}
}