using AutoMapper; using BookingWeb.DB.Model; using BookingWeb.Models; using Resources; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace BookingWeb { public static class AutoMapperConfig { public static void Init() { Mapper.Initialize(cfg => { cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap() .ForMember(x => x.STATUS, map => map.MapFrom(t => t.STATUS == UserStatus.Active.ToString() ? LangSubAccount.EnumStatusActive : LangSubAccount.EnumStatusDisable)) ; cfg.CreateMap() .ForMember(x => x.ISCONTAINERSOC, map => map.MapFrom(t => t.ISCONTAINERSOC ? "1" : "0")) .ForMember(x => x.MODIFYTIME, map => map.MapFrom(t => new DateTime(t.MODIFYTIME))); cfg.CreateMap() .ForMember(x => x.ISCONTAINERSOC, map => map.MapFrom(t => t.ISCONTAINERSOC ? "1" : "0")) .ForMember(x => x.MODIFYTIME, map => map.MapFrom(t => new DateTime(t.MODIFYTIME))) ; cfg.CreateMap() .ForMember(x => x.ISCONTAINERSOC, map => map.MapFrom(t => t.ISCONTAINERSOC == "1" ? true : false)) .ForMember(x => x.ETD, map => map.MapFrom(t => t.ETD.HasValue ? t.ETD.Value.ToString("yyyy-MM-dd") : "")) .ForMember(x => x.MODIFYTIME, map => map.MapFrom(t => t.MODIFYTIME.HasValue ? t.MODIFYTIME.Value.Ticks : 0)) ; cfg.CreateMap() .ForMember(x => x.ISCONTAINERSOC, map => map.MapFrom(t => t.ISCONTAINERSOC == "1" ? true : false)) .ForMember(x => x.ETD, map => map.MapFrom(t => t.ETD.HasValue ? t.ETD.Value.ToString("yyyy-MM-dd") : "")) ; cfg.CreateMap() .ForMember(x => x.ISCONTAINERSOC, map => map.MapFrom(t => t.ISCONTAINERSOC == "1" ? true : false)) .ForMember(x => x.ETD, map => map.MapFrom(t => t.ETD.HasValue ? t.ETD.Value.ToString("yyyy-MM-dd") : "")) .ForMember(x => x.MODIFYTIME, map => map.MapFrom(t => t.MODIFYTIME.HasValue ? t.MODIFYTIME.Value.Ticks : 0)) ; cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap() .ForMember(x => x.BSSTATUS_NAME, map => map.MapFrom(t => ((OrderStatus)Enum.Parse(typeof(OrderStatus), t.BSSTATUS)).GetDesp())) .ForMember(x => x.SISTATUS_NAME, map => map.MapFrom(t => ((OrderConfirmStatus)Enum.Parse(typeof(OrderConfirmStatus), t.SISTATUS)).GetDesp())) .ForMember(x => x.ETD, map => map.MapFrom(t => t.ETD.HasValue ? t.ETD.Value.ToString("yyyy-MM-dd") : "")) ; cfg.CreateMap() .ForMember(x => x.BSSTATUS_NAME, map => map.MapFrom(t => ((OrderConfirmStatus)Enum.Parse(typeof(OrderConfirmStatus), t.BSSTATUS)).GetDesp())) .ForMember(x => x.ETD, map => map.MapFrom(t => t.ETD.HasValue ? t.ETD.Value.ToString("yyyy-MM-dd") : "")) ; cfg.CreateMap() .ForMember(x => x.OpTime, map => map.MapFrom(t => t.OpTime.ToString("yyyy-MM-dd HH:mm:ss"))) .ForMember(x => x.Module, map => map.MapFrom(t => ((OpLogModule)Enum.Parse(typeof(OpLogModule), t.Module)).GetDesp())) .ForMember(x => x.Type, map => map.MapFrom(t => ((OpLogType)Enum.Parse(typeof(OpLogType), t.Type)).GetDesp())) ; }); } } }