using AutoMapper;
using Qusion.Cms.Classifications;
using Qusion.Cms.Classifications.Core;
using System.Linq;

namespace Qusion.WebApp.Areas.cms.Models.Classifications
{
    public class ClassificationProfile : Profile
    {
        protected override void Configure()
        {
            Mapper.CreateMap<Classification, ClassificationListModel>()
                .ForMember(x => x.Labels, o => o.MapFrom(x => x.Labels.Where(y => y.Parent == null)));
            Mapper.CreateMap<Classification, ClassificationSimpleModel>();
            Mapper.CreateMap<Classification, ClassificationModel>()
                .ForMember(x => x.Labels, o => o.MapFrom(x => x.Labels.Where(y => y.Parent == null)))
                .ForMember(x => x.Type, o => o.Ignore());

            Mapper.CreateMap<ClassificationQueryInput, ClassificationQuery>()
                .ConstructUsing(x => ClassificationQuery.Default);
        }
    }
}