using AutoMapper;
using Lada.Framework.Data.Domains.Categories;
using Lada.Framework.Data.Domains.Cms;
using Lada.Framework.Data.Domains.Crm;
using Lada.Framework.Data.Domains.Hr;
using ladaexpress.vn.Infrastructures.DTO.Models.Categories;
using ladaexpress.vn.Infrastructures.DTO.Models.Hr;
using ladaexpress.vn.Infrastructures.DTO.Models.Post.Detail;
using ladaexpress.vn.Infrastructures.DTO.Models.Post.Index.Childs;
using ladaexpress.vn.Infrastructures.DTO.Models.Product.Index.Childs;
using ladaexpress.vn.Infrastructures.DTO.Models.Products.Detail;
using ladaexpress.vn.Infrastructures.DTO.Models.Service;
using ladaexpress.vn.Infrastructures.DTO.Models.Tags;
using ladaexpress.vn.Infrastructures.DTO.Models.Topic;

namespace ladaexpress.vn.Infrastructures.DTO
{
    public static class MappingExtensions
    {
        public static MapperConfiguration MapperConfiguration;

        public static TDestination MapTo<TSource, TDestination>(this TSource source)
        {
            return AutoMapperConfig.Mapper.Map<TSource, TDestination>(source);
        }
        public static TDestination MapTo<TSource, TDestination>(this TSource source, TDestination destination)
        {
            return AutoMapperConfig.Mapper.Map(source, destination);
        }



        #region CMS

        #region Category

        public static CategoryDetailModel ToDetailModel(this Category entity)
        {
            return entity.MapTo<Category, CategoryDetailModel>();
        }

        #endregion

        #region Tag

        public static TagDetailModel ToDetailModel(this Tag entity)
        {
            return entity.MapTo<Tag, TagDetailModel>();
        }

        #endregion

        #region Post

        public static PostItem ToItem(this Post entity)
        {
            return entity.MapTo<Post, PostItem>();
        }
        public static PostDetailModel ToDetailModel(this Post entity)
        {
            return entity.MapTo<Post, PostDetailModel>();
        }

        #endregion

        #region Product

        public static ProductItem ToItem(this Product entity)
        {
            return entity.MapTo<Product, ProductItem>();
        }
        public static ProductDetailModel ToDetailModel(this Product entity)
        {
            return entity.MapTo<Product, ProductDetailModel>();
        }

        #endregion

        #region Category
        public static PostIndexCategory ToPostIndexCategory(this Category entity)
        {
            return entity.MapTo<Category, PostIndexCategory>();
        }
        #endregion


        #region Topic


        public static TopicDetailModel ToDetailModel(this Topic entity)
        {
            return entity.MapTo<Topic, TopicDetailModel>();
        }

        #endregion

        #endregion


        #region HR
        public static JobDetailModel ToDetailModel(this JobPost entity)
        {
            return entity.MapTo<JobPost, JobDetailModel>();
        }

        public static Candidate ToCandidate(this ApplyModel entity)
        {
            return entity.MapTo<ApplyModel, Candidate>();
        }
        #endregion


        #region CRM

        #region Lead

        /// <summary>
        /// Chuyển đổi đối tượng Lead sang LeadModel.
        /// </summary>
        public static Lead ToEntity(this LeadModel model)
        {
            return model.MapTo<LeadModel, Lead>();
        }

        #endregion




        #endregion

    }
}
