galaeth-draft/Galaeth.Services/Profiles/AutomapperProfile.cs

24 lines
737 B
C#
Raw Permalink Normal View History

2024-11-17 10:31:01 +01:00
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()));
}
}