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 = _barangServices.GetById(((BarangModel)_view.ListDataGrid.SelectedItem).id); _barangServices.Delete(model); Messages.InfoDelete(_typeName); if (_listObjs.Remove((BarangModel)_view.ListDataGrid.SelectedItem)) { _bindingView.DataSource = _listObjs; } } catch (DataAccessException ex) { Messages.Error(ex); } finally { if (_view.ListDataGrid.SelectedItem != null) { _view.ListDataGrid.SelectedItem = null; } } } } }
private void ShouldReturnSuccessForDelete() { var operationSecceded = false; var dataAccessJsonStr = string.Empty; var formattedJsonStr = string.Empty; try { var model = new BarangModel() { id = 11, }; _services.Delete(model); operationSecceded = true; } catch (DataAccessException ex) { operationSecceded = ex.DataAccessStatusInfo.OperationSucceeded; dataAccessJsonStr = JsonConvert.SerializeObject(ex.DataAccessStatusInfo); formattedJsonStr = JToken.Parse(dataAccessJsonStr).ToString(); } try { Assert.True(operationSecceded); _testOutputHelper.WriteLine("Data berhasil dihapus."); } finally { _testOutputHelper.WriteLine(formattedJsonStr); } }