private bool EditFlight(FlightModel flight) { var editWindow = new EditFlightWindow(); var ctx = (EditFlightViewModel)editWindow.DataContext; var flightCopy = new FlightModel(); CopyFields(flight, flightCopy); ctx.Flight = flightCopy; ctx.Routes = _routeService.GetAllRoutes(); ctx.Airplanes = _airplaneService.GetAllAirplanes(); flightCopy.RouteModel = ctx.Routes.Single(r => r.Id == flightCopy.RouteModel.Id); if (editWindow.ShowDialog() != true) { return(false); } var errs = GetModelErrors(flightCopy); if (errs != string.Empty) { ShowError(errs, "Error! Saving cancelled. "); return(false); } CopyFields(flightCopy, flight); _flightService.EditFlight(flight); return(true); }