示例#1
0
        /******************************************************************CheckOut***************************************************************/
        public ActionResult CheckOut()
        {
            int count = 0;

            if (selectedItems.Count > 0)
            {
                foreach (CartModel item in selectedItems)
                {
                    totalPrice = totalPrice + item.TotalPrice;
                }
            }

            count = dao.AddTransaction(Session.SessionID + count, DateTime.Now, totalPrice /* Session["username"].ToString()*/);
            //count = dao.AddTransaction(/*Session.SessionID + */count.ToString(), DateTime.Now, totalPrice, Session["username"].ToString());
            //Response.Write(count);

            if (selectedItems.Count >= 0)
            {
                foreach (CartModel item in selectedItems)
                {
                    dao.AddTransactionItem(Session.SessionID + count, item);
                }
            }

            //Session.Clear();
            //Session.Abandon();
            count++;
            return(View());
        }
示例#2
0
        public ActionResult CheckOut(FormCollection form)
        {
            int count  = 0;
            int count1 = 0;
            int count2 = 0;

            string email            = Session["email"].ToString();
            int    shippingid       = int.Parse(form["shipping"]);
            string creditcardnumber = form["creditcard"];

            decimal shippingcharges = dao.CheckShippingCharges(shippingid);

            dao.AddShippingToCart(shippingid, email);

            List <Product> list = dao.ShowAllProductsInCart(email);

            if (list.Count > 0)
            {
                foreach (var product in list)
                {
                    product.TotalPrice = product.Quantity * product.Price;
                    totalPrice         = totalPrice + product.TotalPrice;
                }
            }


            totalPrice = totalPrice + shippingcharges;
            decimal.Round(totalPrice, 2);
            ViewBag.Price = totalPrice;
            dao.UpdateCartCost(email, totalPrice);

            if (Businesslogic.Mod10Check(creditcardnumber) == true)
            {
                count = dao.AddTransaction(Session.SessionID + count, email, DateTime.Now, totalPrice);
                if (count > 0) //if the transaction is successfully placed, then the cart status is changed and a new cart is created for this customer
                {
                    count1 = dao.UpdateCartAfterSuccessfulTransaction(email, DateTime.Now);
                    if (count1 > 0)
                    {
                        count2 = dao.CreateCartAfterSuccessfulTransaction(email);
                        if (count2 > 0)
                        {
                            ViewBag.Status = "Order succesfully placed, we'll be in touch!";
                        }
                        else
                        {
                            ViewBag.Status = "Error!" + dao.message;
                        }
                    }
                    else
                    {
                        ViewBag.Status = "Error!" + dao.message;
                    }
                }
            }
            else
            {
                ViewBag.Status = "You have not entered a valid credit card number";
            }

            return(View("Status"));
        }