private void btnAddMovie_Click(object sender, RoutedEventArgs e) { if (_addEditWindow?.OnMovieActionCallback != null) { _addEditWindow.OnMovieActionCallback -= OnMovieActionCallback; } _addEditWindow = new AddEditWindow(); _addEditWindow.OnMovieActionCallback += OnMovieActionCallback; _addEditWindow.Show(); }
private void btnEditMovie_Click(object sender, RoutedEventArgs e) { if (_addEditWindow?.OnMovieActionCallback != null) { _addEditWindow.OnMovieActionCallback -= OnMovieActionCallback; } string id = ((Button)sender).CommandParameter?.ToString(); ApiResult ret = APIController.RequestGetMoviesByIds(id); MovieInfo movieInfo = ((MovieInfo[])ret.Data).Length != 1 ? null : ((MovieInfo[])ret.Data)[0]; if (movieInfo == null) { MessageBox.Show("Unable to get movie infomation."); return; } _addEditWindow = new AddEditWindow(AddEditWindow.ActionType.Edit, movieInfo); _addEditWindow.OnMovieActionCallback += OnMovieActionCallback; _addEditWindow.Show(); }