using Brizco.Domain.Entities.Complex;
using Brizco.Domain.Entities.Shift;
using Mapster;

namespace Brizco.Domain;

public class MapsterRegister : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        config.NewConfig<Shift, ShiftSDto>()
            .Map("Days", org => org.Days != null ? org.Days.Select(d=>d.DayOfWeek).ToList() : new List<DayOfWeek>())
            .TwoWays();

        config.NewConfig<ComplexUser, ComplexUserSDto>()
            .Map(s=>s.ComplexName,o=>o.Complex!=null ? o.Complex.Name : string.Empty)
            .Map(s=>s.FirstName,o=>o.User!=null ? o.User.FirstName : string.Empty)
            .Map(s=>s.LastName,o=>o.User!=null ? o.User.LastName : string.Empty)
            .Map(s=>s.InternationalId,o=>o.User!=null ? o.User.NationalId : string.Empty)
            .TwoWays();
    }
}