private void OptionWin_KeyDown(object sender, KeyEventArgs e) { Control ctrl = sender as Control; if (ctrl != null) { if (e.Key == Key.Escape || e.Key == Key.Enter) { OptionVM optionVM = ctrl.DataContext as OptionVM; if (optionVM != null) { if (e.Key == Key.Enter) { optionVM.UpdateOptionParam(); } else { ctrl.DataContext = null; ctrl.DataContext = optionVM; } } ctrl.Background = Brushes.White; } else { ctrl.Background = Brushes.MistyRose; } } }
private List <OptionVM> convertResultToVM(List <Option> resultFromApi, Search search) { List <OptionVM> result = new List <OptionVM>(); foreach (var option in resultFromApi) { OptionVM vm = new OptionVM(); vm.TotalPrice = option.TotalPrice; vm.PricePerPerson = option.PricePerPerson; vm.Currency = option.Currency; vm.OutboundFlight = Mapper.Map <FlightVM>(option.OutboundFlight); vm.InboundFlight = Mapper.Map <FlightVM>(option.InboundFlight); result.Add(vm); } return(result); }
public int SaveOption(OptionVM option) { var optionVM = _mapper.Map <OptionVM>(_optionRepository.Add(new Option(option.OptionDescription))); return(optionVM.OptionId); }