예제 #1
0
        /// <summary>
        /// Deletes transactions based on their message.
        /// </summary>
        public static void DeleteTransactionByMessage(string msg)
        {
            var pairs = new List <ExecValuePair>
            {
                new ExecValuePair("@msg", msg)
            };
            var sqlQuery = $@"delete from [Transaction] where Message = @msg";
            var db       = new DbGateway();

            db.Exec(sqlQuery, pairs);
        }
예제 #2
0
        /// <summary>
        /// Saves a transaction.
        /// </summary>
        /// <param name="transaction">Transaction to store</param>
        public static void SaveTransaction(Transaction transaction)
        {
            var pairs = new List <ExecValuePair>
            {
                new ExecValuePair("@cardNumber", transaction.CreditCard.CreditCardNumber),
                new ExecValuePair("@amount", transaction.AmountInCents),
                new ExecValuePair("@installments", transaction.InstallmentCount),
                new ExecValuePair("@authorized", transaction.Authorized),
                new ExecValuePair("@msg", transaction.Message)
            };
            var sqlQuery =
                $@"insert into [Transaction] (CardNumber, AmountInCents, Installments, Authorized, Message) 
                   values (@cardNumber, @amount, @installments, @authorized, @msg)";

            var db = new DbGateway();

            db.Exec(sqlQuery, pairs);
        }