コード例 #1
0
        internal void CreateOrder(string UserKey, List<Cart> Carts, Shipping Shipping)
        {
            var order = new Order
            {
                Carts = Carts,
                Status = Globals.ORDERSTATUS_INCOMPLETE,
                Statuses = new List<OrderStatus> { new OrderStatus { State = Globals.ORDERSTATUS_INCOMPLETE, Date = DateTime.Now } },
                UserKey = UserKey,
                Shipping = Shipping
            };

            var outdatedOrder = GetIncompleteOrder(UserKey);
            if(outdatedOrder != null)
            {
                Order.Remove(outdatedOrder);
            }

            Order.Add(order);
            SaveChanges();
        }
コード例 #2
0
        public ActionResult Shipping(Shipping Shipping)
        {
            var cartBusiness = new CartBusiness { UserKey = Session.GetUserKey() };
            if (cartBusiness.GetCurrentCartCount() <= 0)
            {
                var ex = new HttpException(400, "");
                ex.Data["ErrType"] = Globals.ERRTYPES.CART_CARTEMPTY;
                throw ex;
            }

            if (ModelState.IsValid)
            {
                var orderBusiness = new OrderBusiness();
                orderBusiness.CreateOrder(cartBusiness.UserKey, cartBusiness.GetCurrentCarts(), Shipping);

                return RedirectToAction("Checkout");
            }
            else
            {
                return View(Shipping);
            }
        }