using AutoMapper;
using Kimuser.Domain;
using Kimuser.Domain.SystemUsers;
using Kimuser.Dto.Items.SystemUsers;
using Kimuser.Dto.Items.Users;
using Kimuser.Dto.Models.SystemUsers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Kimuser.Dto
{
    public class AutoMapperConfig
    {
        #region Properties
        private static MapperConfiguration _mapperConfiguration;
        private static IMapper _mapper;

        /// <summary>
        /// Mapper
        /// </summary>
        public static IMapper Mapper => _mapper;

        /// <summary>
        /// Mapper configuration
        /// </summary>
        public static MapperConfiguration MapperConfiguration => _mapperConfiguration;
        #endregion

        public static void Init()
        {
            try
            {
                _mapperConfiguration = new MapperConfiguration(cfg =>
                {



                    #region SystemUser
                    cfg.CreateMap<SystemUser, SelectOptionUserItem>();
                    cfg.CreateMap<SystemUser, SystemUserModel>();
                    cfg.CreateMap<SystemUserModel, SystemUser>();
                    cfg.CreateMap<SystemUser, SystemUserItem>();
                    cfg.CreateMap<SystemUser, SystemUserLocalItem>()
                        .ForMember(dest => dest.IsLocked, opt => opt.MapFrom(src => src.LockoutEnabled && src.LockoutEnd > DateTimeOffset.Now));
                    //cfg.CreateMap<WalletValue, WalletValue>()
                    //    .ForMember(dest => dest.Id, opt => opt.Ignore())
                    //    .ForMember(dest => dest.CreatedTime, opt => opt.Ignore())
                    //    .ForMember(dest => dest.UpdatedTime, opt => opt.Ignore());
                    //cfg.CreateMap<WalletValue, WalletValueModel>();
                    //cfg.CreateMap<WalletValue, WalletValueItem>();
                    //cfg.CreateMap<WalletValueModel, WalletValue>();


                    #endregion


                });

                _mapper = _mapperConfiguration.CreateMapper();
            }
            catch (Exception ex)
            {

                throw ex;
            }

        }
    }
}
