using System;
using System.Linq;
using AutoMapper;
using Qusion.Cms.Modules.Polls;
using Qusion.Cms.Modules.Polls.Core;
using Qusion.Cms.Users.Core;
using Qusion.Cms.Core.Domain;
using Qusion.Framework;
using Qusion.Cms.Modules.Polls.Domain;
using Qusion.Cms.Modules.Polls.Queries;

namespace Qusion.WebApp.Areas.cms.Models.Polls
{
    /// <summary>
    /// Auto mapping from domain to models classes and vice versa
    /// </summary>
    public class PollProfile : Profile
    {
        private readonly PollService _pollService;

        public PollProfile(PollService pollService)
        {
            _pollService = pollService;
        }

        protected override void Configure()
        {
            CreateMap<Poll, PollListModel>();
            CreateMap<Poll, PollModel>();
    
            CreateMap<PollQuestion, PollQuestionListModel>()
                .ForMember(x => x.PollID, o => o.MapFrom(x => x.Poll.ID));

            CreateMap<PollAnswerVoteCreateModel, PollAnswerVote>();
       

            CreateMap<PollQuestion, PollQuestionModel>()
                .ForMember(x => x.PollID, o => o.MapFrom(x => x.Poll.ID));
             

         
            CreateMap<PollQueryInput, PollQuery>()
                .ConstructUsing(x => PollQuery.Default);

            CreateMap<PollQuestionQueryInput, PollQuery>()
                .ConstructUsing(x => PollQuery.Default);
        }

       
    }
}