예제 #1
0
        public static InvoiceVm MapToViewModel(Entities.Entities.Invoice source)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap <Entities.Entities.Invoice, InvoiceVm>()
                                                 .ForMember(x => x.Customer, y => y.MapFrom(z => CustomerVm.MapToViewModelNoRelations(z.Customer)))
                                                 .ForMember(x => x.Company, y => y.MapFrom(z => CompanyVm.MapToViewModel(z.Company)))

                                                 );

            var mapper      = config.CreateMapper();
            var destination = mapper.Map <InvoiceVm>(source);

            return(destination);
        }
예제 #2
0
        public static OrderVm MapToViewModel(Entities.Entities.Order source)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap <Entities.Entities.Order, OrderVm>()
                                                 .ForMember(x => x.OrderDetails, y => y.MapFrom(z => z.OrderItems.Select(OrderDetailVm.MapToViewModel)))

                                                 .ForMember(x => x.Customer, y => y.MapFrom(z => CustomerVm.MapToViewModelNoRelations(z.Customer)))
                                                 );

            var mapper      = config.CreateMapper();
            var destination = mapper.Map <OrderVm>(source);

            return(destination);
        }