private void dataGridView_Category_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { if (MessageBox.Show("Are you sure you want to delete?", "Delete confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { string id = e.Row.Cells["clmID"].Value.ToString(); CategoryAccess.Delete(id); } else { e.Cancel = true; } }
public IActionResult DeleteCategory(int id) { var errors = new List <string>(); var categoryAccess = new CategoryAccess() { ExpenseConnection = _expenseConnection }; try { _expenseConnection.BeginTransaction(); categoryAccess.Delete(id); _expenseConnection.Commit(); _logger.LogInformation("User : {username} deleted category id '{id}'", LoggedInUser, id); } catch (Exception Ex) { _logger.LogWarning("User : {username} get exception while deleting category with id '{id}' ", LoggedInUser, id); if (_expenseConnection.InTransaction) { _expenseConnection.RollBack(); } LogExecption(Ex, _expenseConnection); errors = new List <string>() { _appConfiguration.Messages.InternalServerError }; } return(Json(new { success = (errors.Count == 0), error = errors })); }
public int Delete(int id) { return(categoryAccess.Delete(id)); }