//
// Copyright (c) alveus.dev. All rights reserved. Licensed under the MIT License.
//
using Astral.Core.Constants;
using Astral.Core.Entities;
using Astral.Services.Dtos;
using AutoMapper;
namespace Astral.Services.Profiles;
///
/// Profile for AutoMapper.
///
public class AutomapperProfile : Profile
{
///
/// Initializes a new instance of the class.
///
public AutomapperProfile()
{
CreateMap()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.RegistrationDate, opt => opt.MapFrom(src => src.CreatedAt))
.ForMember(dest => dest.RegistrationDateTicks, opt => opt.MapFrom(src => src.CreatedAt.Ticks))
.ForMember(dest => dest.UserRole, opt => opt.MapFrom(src => src.Role.ToString()));
CreateMap()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.CreationDate, opt => opt.MapFrom(src => src.CreatedAt))
.ForMember(dest => dest.CreationDateTicks, opt => opt.MapFrom(src => src.CreatedAt.Ticks))
.ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Title))
.ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description))
.ForMember(dest => dest.Internal, opt => opt.MapFrom(src => src.Internal));
CreateMap()
.ForMember(
dest => dest.Availability,
opt => opt.MapFrom((src, dest) =>
Enum.TryParse(src.Availability, true, out Discoverability discoverability)
? discoverability
: Discoverability.None))
.ForMember(dest => dest.Connected, opt => opt.MapFrom(src => src.Connected))
.ForMember(dest => dest.Path, opt => opt.MapFrom(src => src.Path))
.ForMember(dest => dest.DomainId, opt => opt.MapFrom(src => src.DomainId))
.ForMember(dest => dest.NetworkAddress, opt => opt.MapFrom(src => src.NetworkAddress))
.ForMember(dest => dest.NetworkPort, opt => opt.MapFrom(src => src.NetworkPort))
.ForMember(dest => dest.NodeId, opt => opt.MapFrom(src => src.NodeId))
.ForMember(dest => dest.PlaceId, opt => opt.MapFrom(src => src.PlaceId));
}
}