using AutoMapper;
using BookHive.DTO.Author;
using BookHive.DTO.Book;
using BookHive.DTO.Loan;
using BookHive.DTO.Member;
using BookHive.DTO.Review;
using BookHive.Models;

namespace BookHive.MappingProfiles;

public class EntityToDtoMappings : Profile
{
    public EntityToDtoMappings()
    {
        CreateMap<Book, GetBookDto>()
            .ForMember(
                dest => dest.AuthorFullName, 
                opt => 
                    opt.MapFrom(src => 
                        src.Author!.FirstName + " " + src.Author.LastName)
                    );
        CreateMap<Book, GetBookDetailsDto>();
        
        CreateMap<Author, GetAuthorDto>();
        CreateMap<Author, GetAuthorDetailsDto>();
        
        CreateMap<Loan, GetLoanDto>();
        
        CreateMap<Member,  GetMemberDto>();
        CreateMap<Member, GetMemberDetailsDto>();
        
        CreateMap<Review, GetReviewDto>();
    }
}