using System.Linq;
using AutoMapper;
using Qusion.Cms.Users.Core;
using Qusion.Cms.Users.Domain;

namespace Qusion.WebApp.Areas.cms.Models.Users
{
    public class UserProfile : Profile
    {
        protected override void Configure()
        {
            Mapper.CreateMap<User, UserListModel>();

            Mapper.CreateMap<User, UserModel>()
                .ForMember(x => x.Roles, o => o.MapFrom(x => x.Roles.Split(',')))
                .ForMember(x => x.Labels, o => o.MapFrom(x=> x.Labels.Select(y => y.ID)));


            Mapper.CreateMap<UserSettings.GeneralSection, UserSettingsModel>();

            Mapper.CreateMap<UserSettingsInput, UserSettings.GeneralSection>();

            Mapper.CreateMap<UserQueryInput, UserQuery>()
                .ConstructUsing(x => UserQuery.Default);
        }
    }
}