예제 #1
0
파일: CarInventory.cs 프로젝트: rojac07/COM
        public void BuyCar(int carID)
        {
            // Build a SQL statement based on incoming params.
            string myInsertQuery =
                string.Format("DELETE FROM Inventory WHERE CarID = '{0}'", carID);
            try
            {
                // Log car to be purchased.
                LogSale log = new LogSale();
                log.Log(carID);
                log.Dispose();

                // Configure SqlCommand type.
                SqlCommand sqlCmd = new SqlCommand(myInsertQuery);
                sqlCmd.Connection = sqlConn;
                sqlConn.Open();

                // Delete the record.
                sqlCmd.ExecuteNonQuery();

                // Update our context.
                // Could also call MyTransactionVote /  DeactivateOnReturn
                // or use AutoCompleteAttribute.
                ContextUtil.SetComplete();
            }
            catch{ContextUtil.SetAbort();}
        }
        private void Listener_SaleResponse(SaleResponse response)
        {
            SaleComplete?.Invoke(response.Success, response);

            if (response.Success)
            {
                LogSale?.Invoke(response.Payment.amount, DateTime.Now, response.Payment.externalPaymentId, response);
            }
        }