using System;
using AutoMapper;
using Qusion.Cms.Core.Domain;
using Qusion.Cms.Modules.Newsletters.Core;
using Qusion.Cms.Modules.Newsletters.Domain;
using Qusion.Framework;

namespace Qusion.WebApp.Areas.cms.Models.Newsletters
{
    /// <summary>
    /// Auto mapping from domain to models classes and vice versa
    /// </summary>
    public class  NewsletterProfile : Profile
    {
        private readonly NewsletterService _newsletterService;

        public NewsletterProfile(NewsletterService newsletterService)
        {
            _newsletterService = newsletterService;
        }

        protected override void Configure()
        {
            CreateMap<Newsletter, NewsletterListModel>();
            CreateMap<Newsletter, NewsletterModel>();
            CreateMap<NewsletterCreateModel, Newsletter>();
         

            CreateMap<NewsletterQueryInput, NewsletterQuery>()
               .ConstructUsing(x => NewsletterQuery.Default);

            CreateMap<NewsletterCreateModel, Newsletter>()
                .ForMember(x => x.Status, o => o.MapFrom(x => Enumeration.FromValue<WorkflowStatus>(x.Status)));

            CreateMap<Newsletter, NewsletterModel>()
                .ForMember(x => x.Status, o => o.MapFrom(x => x.Status.Value));


       
        }    
    }
}