Esempio n. 1
0
 public string Update(Payment c)
 {
     YogaEntities ey = new YogaEntities();
     Payment cc = ey.Payment.FirstOrDefault((ccc) => ccc.Id == c.Id);
     if (cc == null) return string.Format("顾问为{0}的教练不存在", c.Id);
     cc.Money = c.Money;
     cc.Date = c.Date;
     return ey.SaveChanges() == 1 ? "成功" : "失败";
 }
Esempio n. 2
0
 public Payment[] Search(Payment c, DateTime dateStart, DateTime dateEnd, ref int page, int pageSize, out int totalPages)
 {
     YogaEntities ey = new YogaEntities();
     var query = from cc in ey.Payment where cc.Date >= dateStart && cc.Date <= dateEnd select cc;
     if (c.Id > 0) query = query.Where((cc) => cc.Id == c.Id);
     if (c.GoodsId > 0) query = query.Where((cc) => cc.GoodsId == c.GoodsId);
     totalPages = (int)Math.Ceiling(query.Count() * 1.0 / pageSize);
     if (totalPages < 1)
     {
         page = 0;
         return null;
     }
     if (page == -1 || page > totalPages) page = totalPages;
     else if (page < 1) page = 1;
     return query.OrderBy((cc) => cc.Id).Skip((page - 1) * pageSize).Take(pageSize).ToArray();
 }
Esempio n. 3
0
        public bool ValidatePayment(Model.Payment py)
        {
            bool status = false;

            if (py.Cart_id != 0 & py.Ship_id != 0 & py.Uid != 0 & py.CardNumber != null & py.Totalamount != 0)
            {
                if (pyd.InsertPaymentDetail(py))
                {
                    status = true;
                }
                else
                {
                    status = false;
                }
            }
            return(status);
        }
Esempio n. 4
0
        /*Function which add a new payment for a conference.
         * IN:Participant,paidSum from form
         * Out:New Payment with current date,nrTickets,success of transaction
         * Condition:Participant is normal user
         */
        public void addPayment(Participant participant, int nrTickets, Model.Conference conference)
        {
            if (nrTickets == 0)
            {
                throw new Exception("No tickets selected");
            }
            else if (participant.IsNormalUser)
            {
                int            conferenceId             = participant.ConferenceId;
                RepoConference repo                     = new RepoConference(_context);
                double         priceTicketForConference = conference.AdmissionPrice;
                double         paidSum                  = 0;
                if (priceTicketForConference != 0)
                {
                    paidSum = nrTickets * priceTicketForConference;
                }
                else
                {
                    throw new Exception("You can participate for free.Enjoy!");
                }
                DateTime      PaymentDate           = DateTime.Now;
                bool          SuccessfulTransaction = true;
                Model.Payment payment = new Model.Payment(10, paidSum, nrTickets, PaymentDate, SuccessfulTransaction, participant);


                Payment payment1 = new Payment();
                payment1.PaymentId             = payment.Id;
                payment1.PaymentDate           = payment.PaymentDate;
                payment1.NrOfTickets           = payment.NrOfTickets;
                payment1.PaidSum               = payment.PaidSum;
                payment1.SuccessfulTransaction = payment.SuccessfulTransaction;
                _context.Payments.Add(payment1);
                _context.SaveChanges();

                ConferenceParticipant confP = new ConferenceParticipant();    //daca a facut plata devine un participant la conferinta.
                if (_context.ConferenceParticipants.Find(payment.Buyer.User.IdUser, conference.Id, payment1.PaymentId) == null)
                {
                    confP.UserId       = participant.User.IdUser;
                    confP.ConferenceId = conference.Id;
                    confP.PaymentId    = payment1.PaymentId;
                    _context.ConferenceParticipants.Add(confP);
                    _context.SaveChanges();
                }
            }
        }
Esempio n. 5
0
        public bool InsertPaymentDetail(Model.Payment py)
        {
            SqlConnection con = new SqlConnection(SqlCon.constring);

            con.Open();
            SqlCommand cmd = new SqlCommand("insert into payment_details values(@id,@uid,@cartid,@shipid,@amount,@cardnumber,@expirynumber,@cvv,@status,@date)", con);

            cmd.Parameters.AddWithValue("@id", py.Payment_id);
            cmd.Parameters.AddWithValue("@uid", py.Uid);
            cmd.Parameters.AddWithValue("@cartid", py.Cart_id);
            cmd.Parameters.AddWithValue("@shipid", py.Ship_id);
            cmd.Parameters.AddWithValue("@amount", py.Totalamount);
            cmd.Parameters.AddWithValue("@cardnumber", py.CardNumber);
            cmd.Parameters.AddWithValue("@expirynumber", py.ExpiryDate);
            cmd.Parameters.AddWithValue("@cvv", py.Cvv);
            cmd.Parameters.AddWithValue("@status", py.Status);
            cmd.Parameters.AddWithValue("@date", py.Paymentdate);
            cmd.ExecuteNonQuery();
            con.Close();

            SqlCommand cmd1 = new SqlCommand("update cart set status=@status where cart_id=@cartid and uid=@uid", con);

            con.Open();
            cmd1.Parameters.AddWithValue("@status", "paid");
            cmd1.Parameters.AddWithValue("@uid", py.Uid);
            cmd1.Parameters.AddWithValue("@cartid", py.Cart_id);
            int cnt = cmd1.ExecuteNonQuery();

            con.Close();
            Cart    c = new Cart();
            Product p = new Product();

            p.UpdateProductStock(c.GetQuantityByUid(py.Uid, py.Cart_id));
            if (cnt > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public Payment FirstClient1Payment()
        {
            var FirstInvoice = new FakeClient1Invoices().FirstInvoice();
            if (FirstInvoice.OrderId != null)
            {
                var Payment = new Payment
                {
                    PaymentId = 1,
                    InvoiceId = FirstInvoice.InvoiceId,
                    PaymentDate = DateTime.Now.Date,
                    PaymentAmount = FirstInvoice.Total,
                    OrderId = (int) FirstInvoice.OrderId,
                    ClientId = FirstInvoice.ClientId,
                    CookerId = FirstInvoice.CookerId,
                    TransactionId = "G126F85"
                };

                return Payment;
            }
            return null;
        }
Esempio n. 7
0
        public Payment FirstClient1Payment()
        {
            var FirstInvoice = new FakeClient1Invoices().FirstInvoice();
            if (FirstInvoice.OrderId != null)
            {
                var Payment = new Payment
                {
                    PaymentId = 1,
                    InvoiceId = FirstInvoice.InvoiceId,
                    PaymentDate = DateTime.Now.Date,
                    PaymentAmount = FirstInvoice.Total,
                    OrderId = (int) FirstInvoice.OrderId,
                    ClientId = FirstInvoice.ClientId,
                    CookerId = FirstInvoice.CookerId,
                    TransactionId = "G126F85",
                    OrderModelTypeId = (int)LookUp.OrderModel.OrderModelType.Values.Transaction,
                    PaymentStatusId = (int)PaymentStatusType.Values.Pending

                };

                return Payment;
            }
            return null;
        }
Esempio n. 8
0
        protected void BtnConfirm_Click(object sender, EventArgs e)
        {
            Controller.Payment pyc = new Controller.Payment();
            Model.Payment      py  = new Model.Payment();
            Random             rnd = new Random();

            py.Payment_id        = rnd.Next(19898876, 99999999);
            Session["PaymentId"] = py.Payment_id;
            py.CardNumber        = DebitCard.Text;
            py.ExpiryDate        = ExpiryMonth.Text + "/" + ExpiryYear.Text;
            py.Cvv         = EncryptionDecryption.EncodePasswordToBase64(CVVCode.Text);
            py.Uid         = int.Parse(Session["UserId"].ToString());
            py.Cart_id     = int.Parse(Session["CartId"].ToString());
            py.Ship_id     = int.Parse(Request.QueryString["shipid"].ToString());
            py.Totalamount = double.Parse(Session["TotalAmount"].ToString());
            py.Status      = "paid";
            py.Paymentdate = DateTime.Now;
            bool status = pyc.ValidatePayment(py);

            if (status)
            {
                Response.Redirect("PaymentSuccessful.aspx");
            }
        }
Esempio n. 9
0
 public void NewPayment(Model.Payment p)
 {
     //adauga payment, notifica
     throw new NotImplementedException();
 }
Esempio n. 10
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Payment EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPayment(Payment payment)
 {
     base.AddObject("Payment", payment);
 }
Esempio n. 11
0
 /// <summary>
 /// Create a new Payment object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="money">Initial value of the Money property.</param>
 /// <param name="remarks">Initial value of the Remarks property.</param>
 public static Payment CreatePayment(global::System.Int32 id, global::System.DateTime date, global::System.Double money, global::System.String remarks)
 {
     Payment payment = new Payment();
     payment.Id = id;
     payment.Date = date;
     payment.Money = money;
     payment.Remarks = remarks;
     return payment;
 }
Esempio n. 12
0
        private void ClientPaySubscriptionInvoice(Invoice subscriptionInvoice)
        {
            Debug.Assert(subscriptionInvoice.OrderId != null, "subscriptionInvoice.OrderId != null");
            var clientPaymentCount = _uow.PaymentRepository.All.Count(x => x != null && x.InvoiceId == subscriptionInvoice.InvoiceId);
            Assert.AreEqual(0, clientPaymentCount);
            var clientSubscriptionPayment = new Payment
                {
                    PaymentId = 1,
                    InvoiceId = subscriptionInvoice.InvoiceId,
                    PaymentDate = DateTime.Now.Date,
                    PaymentAmount = subscriptionInvoice.Total,
                    OrderId = (int)subscriptionInvoice.OrderId,
                    ClientId = subscriptionInvoice.ClientId,
                    CookerId = subscriptionInvoice.CookerId,
                    TransactionId = new Guid().ToString(),
                    OrderModelTypeId = (int)OrderModelType.Values.Transaction,
                    PaymentStatusId = (int)PaymentStatusType.Values.Pending

                };
            _uow.PaymentRepository.Add(clientSubscriptionPayment);
            _uow.Save();
            var clientPaymentCountUpdate = _uow.PaymentRepository.All.Count(x => x != null && x.InvoiceId == subscriptionInvoice.InvoiceId);
            Assert.AreEqual(1, clientPaymentCountUpdate);
        }
 public Task <PaymentRedirect> Get(Model.Payment payment)
 {
     // In reality, call the provider using the provided settings.
     return(Task.FromResult(new PaymentRedirect(new Uri("https://paymentProvider/Redirect"))));
 }
Esempio n. 14
0
 public int Add(Payment a)
 {
     YogaEntities ey = new YogaEntities();
     ey.AddToPayment(a);
     return ey.SaveChanges() == 1 ? a.Id : -1;
 }