private void ShouldReturnSuccessForDelete() { var operationSecceded = false; var dataAccessJsonStr = string.Empty; var formattedJsonStr = string.Empty; try { var model = new RoleModel() { id = 1, kode = "role" }; _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); } }
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(((RoleModel)_view.ListDataGrid.SelectedItem).id); _services.Delete(model); Messages.InfoDelete(_typeName); if (_listObjs.Remove((RoleModel)_view.ListDataGrid.SelectedItem)) { _bindingView.DataSource = _listObjs; } } catch (DataAccessException ex) { Messages.Error(ex); _view_OnRefreshData(null, null); } finally { if (_view.ListDataGrid.SelectedItem != null) { _view.ListDataGrid.SelectedItem = null; } } } } }
public IActionResult Delete(int id) { try { _role.Delete(id); return(Ok("Role deleted successfully.")); }catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public ActionResult Delete(int id) { var role = _roleServices.GetById(id); if (role.IsSys) { AR.SetWarning("系统角色,不可以删除!"); return(Json(AR)); } _roleServices.Delete(role); return(Json(AR)); }
private string InitDelete(long ID) { try { if (ID != 0) { RoleServices.Delete(ID); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Notification", MessageBoxButton.OK); } return("Role deleted."); }
public ActionResult Delete(int id) { var role = _roleServices.GetById(id); if (role.IsSys) { AR.SetWarning("系统角色,不可以删除!"); return(Json(AR, JsonRequestBehavior.DenyGet)); } if (role == null) { AR.Setfailure("未找到此角色!"); return(Json(AR, JsonRequestBehavior.DenyGet)); } _roleServices.Delete(role); return(Json(AR, JsonRequestBehavior.DenyGet)); }
public ActionResult Delete(int id) { if (RoleServices.Delete(id)) { return(Ok(new Result { State = 1, Message = "删除成功" })); } else { return(BadRequest(new Result { State = 0, Message = "删除失败" })); } }
// ----------------------------------------------------------------------// #region >> Update Role << /// <summary> /// Method yang digunakkan untuk mengupdate data role pada tabel role_detail /// sesuai dengan node yang tercentang pada TreeView /// </summary> /// <param name="roleKode">Role kode</param> /// <param name="menuParent">Menu (parent/header) terpilih</param> public void UpdateRole(string roleKode, string menuParent) { // Buat object RoleDetail yang ingin di update var roleDetail = new RoleDetailModel() { role_kode = roleKode, menu_name = null, menu_parent = menuParent, // Menu header (parent) di MenuStrip form_action = null, tag = null }; // Hapus semua data sesuai role kode dan menu parent terpilih _roleServices.Delete(roleDetail); var listRoleDetail = new List <RoleDetailModel>(); // isi data role detail sesuai node yang di check InsertItemChecked(listRoleDetail, roleKode, menuParent, TreeView.Nodes); _roleServices.Insert(listRoleDetail); }