private void ShouldReturnSuccessForUpdate() { var operationSecceded = false; var dataAccessJsonStr = string.Empty; var formattedJsonStr = string.Empty; try { var model = new TipeModel() { id = 1, nama = "Tipe #1 (Update)", keterangan = "Keterangan Tipe #1" }; _services.Update(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 diubah."); } finally { _testOutputHelper.WriteLine(formattedJsonStr); } }
private void TipeEntryView_OnSaveData(object sender, EventArgs e) { using (new WaitCursorHandler()) { try { var listDataGrid = _view.ListDataGrid; var newModel = ((ModelEventArgs <TipeModel>)e).Value; var view = ((TipeEntryView)sender); if (newModel.id == default(uint)) { _services.Insert(newModel); view.Controls.ClearControls(); Messages.InfoSave(_typeName); _listObjs.Add(newModel); _bindingView.DataSource = _listObjs; if (listDataGrid.SelectedItem != null) { listDataGrid.SelectedItem = null; } listDataGrid.SelectedItem = newModel; } else { _services.Update(newModel); Messages.InfoUpdate(_typeName); view.Close(); var model = _bindingView.Where(b => b.id == newModel.id).FirstOrDefault(); if (model != null) { model.nama = newModel.nama; model.keterangan = newModel.keterangan; _bindingView.Refresh(); } } } catch (ArgumentException ex) { Messages.Error(ex); } catch (DataAccessException ex) { Messages.Error(ex); } } }