Exemplo n.º 1
0
        public void StoreCustomerInfo(CustomerInfo ci)
        {
            var db = new LaSuBuContainer();

            var currentDate = DateTime.Now;
            Transaction currentTrans = new Transaction
                {
                    Address = ci.Address,
                    Amount = Session["totalAmount"].ToString(),
                    City = ci.City,
                    CustomerName = ci.Name,
                    Date = currentDate,
                    Email = ci.Email,
                    Phone = ci.Phone,
                    Zip = ci.Zip,
                    State = ci.State,
                    Status = "Failed"
                };

            db.Transactions.Add(currentTrans);
            db.SaveChanges();
            //setUsername / id of transaction in session to persist PayPal Info
            Session["customerName"] = ci.Name;
            Session["transId"] = currentTrans.Id;
        }
Exemplo n.º 2
0
 protected int GetTrans()
 {
     string Token = Request.QueryString["token"];
        LaSuBuContainer DB = new LaSuBuContainer();
     var trans = (from x in DB.Transactions
                   where Token == x.Token
                   select x).SingleOrDefault();
     int dbTransId = trans.Id;
     return dbTransId;
 }
Exemplo n.º 3
0
 protected void lvShop_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
 {
     this.lvShop.SelectedIndex = e.NewSelectedIndex;
     LaSuBuContainer db = new LaSuBuContainer();
     var selectedItem = int.Parse(lvShop.SelectedValue.ToString());
     var dsSelectedItem = db.StoreItems.Where(n => n.Id == selectedItem).ToArray();
     lvSelectedItem.DataSource = dsSelectedItem;
     lvSelectedItem.DataBind();
     mvShop.SetActiveView(vwProduct);
 }
Exemplo n.º 4
0
 protected void btnAddContent_Click(object sender, EventArgs e)
 {
     LaSuBuContainer db = new LaSuBuContainer();
     db.ContentManagements.Add(new ContentManagement
     {
         PageName = ddlPage.SelectedValue,
         Headline = tbHeadline.Text,
         Content = tbContent.Text
     }
     );
     db.SaveChanges();
 }
Exemplo n.º 5
0
 protected void StorePaymentInfo()
 {
     var transId = GetTrans();
     LaSuBuContainer DB  = new LaSuBuContainer();
     var storeTrans = (from x in DB.Transactions
                              where x.Id == transId
                              select x).FirstOrDefault();
     storeTrans.Token = Request.QueryString["token"];
     storeTrans.PayerID = Request.QueryString["PayerId"];
     storeTrans.ReferenceId = Session["transRef"].ToString();
     storeTrans.Status = "Payment Received";
     DB.SaveChanges();
 }
Exemplo n.º 6
0
        protected void btnAddToCart_Click(object sender, EventArgs e)
        {
            LaSuBuContainer db = new LaSuBuContainer();
            //1) the product to be added
            StoreItem theproduct = (from p in db.StoreItems
                                     where p.Id == (int)lvShop.SelectedValue
                                     select p).Single();

            //2) the qty

            //get the tbbox
            //textbox tbqty = (textbox)dvselectedproduct.findcontrol("tbqty");
            //int qty = int.parse(tbqty.text);

               // TextBox ddlQty = (TextBox).FindControl("ddlQty");
            DropDownList ddlQty = (DropDownList)lvSelectedItem.Items[0].FindControl("ddlQty");
            DropDownList ddlSize = (DropDownList)lvSelectedItem.Items[0].FindControl("ddlSize");
            DropDownList ddlColor = (DropDownList)lvSelectedItem.Items[0].FindControl("ddlColor");
            //Label lblTest = new Label();
            // lblTest.Text = ddlQty.Text;
            //or
            int qty = int.Parse(ddlQty.SelectedValue.ToString());
            string size = ddlSize.SelectedValue.ToString();
            string color = ddlColor.SelectedValue;
            //cart item
            CartItem item = new CartItem(theproduct, qty, size, color);

            //cart logic
            List<CartItem> cart = null;

            //is the cart already in the session
            if (Session["cart"] != null)
            {
                //cart is already in the session
                cart = (List<CartItem>)Session["cart"];
            }
            else
            {
                //no cart in the session create a new one
                cart = new List<CartItem>();
            }

            //add the item to the cart
            cart.Add(item);

            //put the cart back in the session
            Session["cart"] = cart;
            //mvShop.SetActiveView(vwConfirm);
            mvShop.SetActiveView(vwConfirm);
            lblConfirm.Text = "Item has been added to your cart";
        }
Exemplo n.º 7
0
        public void GeneratePayPalToken()
        {
            List<CartItem> cart = (List<CartItem>)Session["cart"];

            string userId = System.Configuration.ConfigurationManager.AppSettings["userId"].ToString();
            string password = System.Configuration.ConfigurationManager.AppSettings["password"].ToString();
            string signature = System.Configuration.ConfigurationManager.AppSettings["signature"].ToString();

            decimal amount = (decimal)cart.Sum(ci => ci.Qty * decimal.Parse(ci.Product.Cost));
            var configuration = new Moolah.PayPal.PayPalConfiguration(PaymentEnvironment.Live, userId, password, signature);
            var gateway = new Moolah.PayPal.PayPalExpressCheckout(configuration);
            //var cancelURL = "http://www.lasubu.com/";
            //var confirmationUrl = "http://www.lasubu.com/confirmation.aspx";
            var cancelURL = "http://localhost:9999/";
            var confirmationUrl = "http://localhost:9999/confirmation.aspx";

            var request = gateway.SetExpressCheckout(new Moolah.PayPal.OrderDetails
            {
                OrderTotal = amount,
                Items = new[]
                    {
                    new Moolah.PayPal.OrderDetailsItem{UnitPrice = decimal.Parse(Session["totalAmount"].ToString()), Description = "Goods from LaSuBu.com"}
                    },
                CurrencyCodeType = Moolah.PayPal.CurrencyCodeType.USD
            }, cancelURL, confirmationUrl);
            if (request.Status == PaymentStatus.Failed)
            {
                throw new Exception(request.FailureMessage);
            }
            else
            {

                var getTransId = Session["transId"].ToString();
                var transId = int.Parse(getTransId);

                LaSuBuContainer DB = new LaSuBuContainer();
                Transaction updateTrans = (from x in DB.Transactions where x.Id == transId select x).SingleOrDefault();
                updateTrans.Token = request.PayPalToken;
                DB.SaveChanges();

                Response.Redirect(request.RedirectUrl);
            }
        }
Exemplo n.º 8
0
        public void StoreTransactionItems()
        {
            LaSuBuContainer DB = new LaSuBuContainer();
            var getTransId = Session["transId"].ToString();
            var transId = int.Parse(getTransId);
            foreach (var item in (List<CartItem>)Session["cart"])
            {
                TransItem ti = new TransItem
                    {
                        Name = item.Product.ItemName,
                        Qty = item.Qty,
                        Size = item.Size,
                        Color = item.Color,
                        Price = item.Product.Cost,
                        TransactionId = transId
                    };

                DB.TransItems.Add(ti);
            }
            DB.SaveChanges();
        }