private bool AddPassenger(PassengerModel passengerModel) { var editWindow = new EditPassengerWindow(); var ctx = (EditPassengerViewModel)editWindow.DataContext; ctx.Passenger = passengerModel; if (editWindow.ShowDialog() != true) { return(false); } var errs = GetModelErrors(ctx.Passenger); if (errs != string.Empty) { ShowError(errs, "Error! Saving cancelled. "); return(false); } _passengerService.AddPassenger(passengerModel); return(true); }
private bool EditPassenger(PassengerModel passenger) { var editWindow = new EditPassengerWindow(); var ctx = (EditPassengerViewModel)editWindow.DataContext; var passengerCopy = new PassengerModel(); CopyFields(passenger, passengerCopy); ctx.Passenger = passengerCopy; if (editWindow.ShowDialog() != true) { return(false); } var errs = GetModelErrors(passengerCopy); if (errs != string.Empty) { ShowError(errs, "Error! Saving cancelled. "); return(false); } CopyFields(passengerCopy, passenger); _passengerService.EditPassenger(passenger); return(true); }