public override bool RefundPayment(int paymentid) { bool result = false; using (SakilaEntities dc = new SakilaEntities()) { SPayment spayment = new SPayment(); var model = from p in dc.payments where p.payment_id == paymentid //orderby (p.payment_date) select p; List<payment> payments = model.ToList<payment>(); simulator.PerformanceSimulation(); payment refundpayment = new payment(); refundpayment.amount = payments[0].amount * -1; refundpayment.customer_id = payments[0].customer_id; refundpayment.customerReference = payments[0].customerReference; refundpayment.rental_id = payments[0].rental_id; refundpayment.rentalReference = payments[0].rentalReference; refundpayment.payment_date = DateTime.Now; refundpayment.staff_id = payments[0].staff_id; refundpayment.staffReference = payments[0].staffReference; dc.AddTopayments(refundpayment); dc.AcceptAllChanges(); dc.SaveChanges(); } result = true; return result; }
public override bool PayForMovie(byte staffid, byte customerid, byte rentalid, double paymentAmount) { payment payment = new payment(); payment.amount = (decimal)paymentAmount; payment.customer_id = customerid; payment.staff_id = staffid; payment.rental_id = rentalid; using (SakilaEntities dc = new SakilaEntities()) { simulator.PerformanceSimulation(); dc.AddTopayments(payment); dc.SaveChanges(); } return true; }