private bool AddAirplane(AirplaneModel airplaneModel) { var editWindow = new EditAirplaneWindow(); var ctx = (EditAirplaneViewModel)editWindow.DataContext; ctx.Airplane = airplaneModel; if (editWindow.ShowDialog() != true) { return(false); } var errs = GetModelErrors(ctx.Airplane); if (errs != string.Empty) { ShowError(errs, "Error! Saving cancelled. "); return(false); } _airplaneService.AddAirplane(airplaneModel); return(true); }
private bool EditAirplane(AirplaneModel airplane) { var editWindow = new EditAirplaneWindow(); var ctx = (EditAirplaneViewModel)editWindow.DataContext; var airplaneCopy = new AirplaneModel(); CopyFields(airplane, airplaneCopy); ctx.Airplane = airplaneCopy; if (editWindow.ShowDialog() != true) { return(false); } var errs = GetModelErrors(airplaneCopy); if (errs != string.Empty) { ShowError(errs, "Error! Saving cancelled. "); return(false); } CopyFields(airplaneCopy, airplane); _airplaneService.EditAirplane(airplane); return(true); }