public static AjaxResponse ChangeNoteAndReff(int tid, string note, string ref_hash) { ToastrUtilities toastrUtilities = new ToastrUtilities(); using (NpgsqlConnection conn = Classes.DB.InstBTCDB("instbtc")) { #region Added Query string added_query = string.Empty; if (!string.IsNullOrEmpty(note)) { added_query += $"notes='{note}',"; } else { added_query += "notes=notes,"; } if (!string.IsNullOrEmpty(ref_hash)) { added_query += $"payment_reference='{ref_hash}',"; } else { added_query += "payment_reference=payment_reference,"; } #endregion string query = $"UPDATE transactions SET {added_query.TrimEnd(',')} WHERE id = {tid}"; if (!string.IsNullOrEmpty(tid.ToString())) { var sss = Classes.DB.Update(conn, query); toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("success", "Transaction Updated")); } AjaxResponse res = new AjaxResponse() { Success = true, Transaction_id = tid }; return(res); } }
public static AjaxResponse EditReference(string id, string ref_hash) { AjaxResponse res = new AjaxResponse(); var WithdrawalId = Classes.encryption.Decrypt(id); ToastrUtilities toastrUtilities = new ToastrUtilities(); if (!string.IsNullOrEmpty(WithdrawalId) && !string.IsNullOrEmpty(ref_hash)) { string UpdateQuery = "UPDATE withdrawal SET refference_hash = @Reference WHERE id = @Id; "; using (var con = Classes.DB.InstBTCDB("instbtc")) { NpgsqlCommand cmd = new NpgsqlCommand(UpdateQuery, con); cmd.Parameters.AddWithValue("@Reference", ref_hash); cmd.Parameters.AddWithValue("@Id", Convert.ToInt32(WithdrawalId)); var qResult = Classes.DB.Update(con, UpdateQuery, cmd); toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("success", "Successfully Updated Referrence")); res = new AjaxResponse() { Success = true, DocumentId = int.Parse(WithdrawalId) }; } } else { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", "Failed to Update Referrence")); res = new AjaxResponse() { Success = false, DocumentId = 0 }; } return(res); }