private void ShouldReturnSuccessForDelete() { var operationSecceded = false; var dataAccessJsonStr = string.Empty; var formattedJsonStr = string.Empty; try { var model = new SubTipeModel() { id = 12, }; _services.Delete(model); operationSecceded = true; } catch (DataAccessException ex) { operationSecceded = false; formattedJsonStr = TestsHelper.DataAccessStatusInfoToJson(ex); } try { Assert.True(operationSecceded); _testOutputHelper.WriteLine("Data berhasil dihapus."); } finally { _testOutputHelper.WriteLine(formattedJsonStr); } }
private void _view_OnDeleteData(object sender, EventArgs e) { using (new WaitCursorHandler()) { if (_view.ListDataGrid != null && _view.ListDataGrid.SelectedItem != null && Messages.ConfirmDelete(_typeName)) { try { var model = _services.GetById(((SubTipeModel)_view.ListDataGrid.SelectedItem).id); _services.Delete(model); Messages.InfoDelete(_typeName); if (_listObjs.Remove((SubTipeModel)_view.ListDataGrid.SelectedItem)) { _bindingView.DataSource = _listObjs; } } catch (DataAccessException ex) { Messages.Error(ex); } finally { if (_view.ListDataGrid.SelectedItem != null) { _view.ListDataGrid.SelectedItem = null; } } } } }