public string RefundPayment(int paymentid, int customer_id, int staff_id, int rental_id, decimal amount, DateTime paymentDate, string movie_title) { //string conn = "server=localhost; userid=root;password=ecetera;database=sakila;"; //Use the 'client' variable to call operations on the service. string info = ""; CardConsumer cc = new CardConsumer(); //here just use a randon credti card since we are not fully simulating a bank and accounts etc string ccnumber = RandomCreditCardNumberGenerator.GenerateMasterCardNumber(); //apply credit via the bank service cc.Credit(ccnumber, double.Parse(amount.ToString())); //account this refund in sakila database payment table using (MySqlConnection connection = new MySqlConnection(GetConnection())) { MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.Connection = connection; cmd.Parameters.AddWithValue("@customer_id", customer_id); cmd.Parameters.AddWithValue("@staff_id", staff_id); cmd.Parameters.AddWithValue("@rental_id", rental_id); cmd.Parameters.AddWithValue("@amount", amount); cmd.Parameters.AddWithValue("@payment_date", paymentDate); cmd.Parameters.AddWithValue("@lastupdate", DateTime.Now); cmd.CommandText = "INSERT INTO payment(customer_id,staff_id,rental_id,amount,payment_date,last_update) VALUES" + "(@customer_id, @staff_id, @rental_id, @amount, @payment_date, @lastupdate);"; try { connection.Open(); int result = cmd.ExecuteNonQuery(); if (result == -1) { info = "error in refunding amount"; } else { info = "success"; } } finally { connection.Close(); } } return(info); }
public string RefundPayment(int paymentid, int customer_id, int staff_id, int rental_id, decimal amount, DateTime paymentDate, string movie_title) { //string conn = "server=localhost; userid=root;password=ecetera;database=sakila;"; //Use the 'client' variable to call operations on the service. string info = ""; CardConsumer cc = new CardConsumer(); //here just use a randon credti card since we are not fully simulating a bank and accounts etc string ccnumber = RandomCreditCardNumberGenerator.GenerateMasterCardNumber(); //apply credit via the bank service cc.Credit(ccnumber,double.Parse(amount.ToString())); //account this refund in sakila database payment table using (MySqlConnection connection = new MySqlConnection(GetConnection())) { MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); cmd.Connection = connection; cmd.Parameters.AddWithValue("@customer_id", customer_id); cmd.Parameters.AddWithValue("@staff_id", staff_id); cmd.Parameters.AddWithValue("@rental_id", rental_id); cmd.Parameters.AddWithValue("@amount", amount); cmd.Parameters.AddWithValue("@payment_date", paymentDate); cmd.Parameters.AddWithValue("@lastupdate", DateTime.Now); cmd.CommandText = "INSERT INTO payment(customer_id,staff_id,rental_id,amount,payment_date,last_update) VALUES" + "(@customer_id, @staff_id, @rental_id, @amount, @payment_date, @lastupdate);"; try { connection.Open(); int result = cmd.ExecuteNonQuery(); if (result == -1) info = "error in refunding amount"; else info = "success"; } finally { connection.Close(); } } return info; }