Inheritance: System.Data.Objects.DataClasses.EntityObject
示例#1
0
        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;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the payments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTopayments(payment payment)
 {
     base.AddObject("payments", payment);
 }
示例#3
0
        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;
        }
 /// <summary>
 /// Create a new payment object.
 /// </summary>
 /// <param name="payment_id">Initial value of the payment_id property.</param>
 /// <param name="customer_id">Initial value of the customer_id property.</param>
 /// <param name="staff_id">Initial value of the staff_id property.</param>
 /// <param name="amount">Initial value of the amount property.</param>
 /// <param name="payment_date">Initial value of the payment_date property.</param>
 /// <param name="last_update">Initial value of the last_update property.</param>
 public static payment Createpayment(global::System.Int32 payment_id, global::System.Int32 customer_id, global::System.Byte staff_id, global::System.Decimal amount, global::System.DateTime payment_date, global::System.DateTime last_update)
 {
     payment payment = new payment();
     payment.payment_id = payment_id;
     payment.customer_id = customer_id;
     payment.staff_id = staff_id;
     payment.amount = amount;
     payment.payment_date = payment_date;
     payment.last_update = last_update;
     return payment;
 }