예제 #1
0
        public static TypeOfOperationViewModel MapToViewModel(TypeOfOperation typeOfOperation)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <TypeOfOperation, TypeOfOperationViewModel>();
            });

            return(config.CreateMapper().Map <TypeOfOperationViewModel>(typeOfOperation));
        }
예제 #2
0
        public static FlightLogViewModel MapToViewModel(FlightLog flightLog)
        {
            var config = new MapperConfiguration(cfg =>
                                                 {;
                                                  cfg.CreateMap <FlightLog, FlightLogViewModel>();
                                                  //.ForMember(x=>x.FlightLogTypeOfOperations, opt=>opt.Ignore());
                                                 });
            var flightLogViewModel = config.CreateMapper().Map <FlightLogViewModel>(flightLog);

            flightLogViewModel.TypeOfOperationViewModels = new List <TypeOfOperationViewModel>();
            foreach (var typeOfOperation in flightLog.FlightLogTypeOfOperations.Select(x => x.TypeOfOperation).ToList())
            {
                flightLogViewModel.TypeOfOperationViewModels.Add(TypeOfOperation.MapToViewModel(typeOfOperation));
            }
            // TODO: manually automap flightlogtypeofoperations
            return(flightLogViewModel);
        }