public static string DeleteItem(int itemId, string item) { Dictionary <string, string> result = new Dictionary <string, string>() { { "id", itemId.ToString() } , { "item", item } , { "exists", "" } , { "hasDependencies", "" } , { "deleted", "" } , { "archived", "" } , { "error", "" } }; bool exists = false, hasDependencies = false, deleted = false, archived = false; string errorMsg = string.Empty; try { //delete if (itemId == 0) { errorMsg = "You must specify an item to delete."; } else { deleted = MasterData.AllocationCategory_Delete(itemId, out exists, out hasDependencies, out archived, out errorMsg); if (hasDependencies && errorMsg.Length == 0) { errorMsg = "Record has dependencies and could not be permanently deleted. It has been archived instead."; } } } catch (Exception ex) { LogUtility.LogException(ex); deleted = false; errorMsg = ex.Message; } result["exists"] = exists.ToString(); result["hasDependencies"] = hasDependencies.ToString(); result["deleted"] = deleted.ToString(); result["archived"] = archived.ToString(); result["error"] = errorMsg; return(JsonConvert.SerializeObject(result, Formatting.None)); }