Ejemplo n.º 1
0
        public ActionResult AddressAndPayMent(FormCollection values)
        {
            var order = new musicorder();

            TryUpdateModel(order);
            try
            {
                if (string.Equals(values["PromoCode"], PromoCode, StringComparison.OrdinalIgnoreCase) == false)
                {
                    return(View(order));
                }
                else
                {
                    order.Username  = User.Identity.Name;
                    order.OrderDate = DateTime.Now;
                    //保存订单
                    Maticsoft.BLL.musicorder orderbll = new Maticsoft.BLL.musicorder();
                    if (orderbll.Add(order))
                    {
                        int orderid = orderbll.GetMaxId() - 1;
                        var cart    = ShoppingCart.GetCart(this.HttpContext);
                        order.OrderId = orderid;
                        cart.CreateOrder(order);
                    }

                    return(RedirectToAction("Complete", new { id = order.OrderId }));
                }
            }
            catch (Exception e)
            {
                return(View(e));
            }
        }
Ejemplo n.º 2
0
        /*
         * 将购物车转换为结账处理过程中的订单。
         */
        public int  CreateOrder(musicorder order)
        {
            Maticsoft.BLL.cart itembll = new Maticsoft.BLL.cart();
            var cartItems = GetCartItems();

            foreach (var item in cartItems)
            {
                var orderDetail = new orderdetail
                {
                    AlbumId   = item.AlbumId,
                    OrderId   = order.OrderId,
                    Quantity  = item.Count,
                    UnitPrice = itembll.GetUnitprice(item.AlbumId)
                };
                Maticsoft.BLL.orderdetail orderdetailbll = new Maticsoft.BLL.orderdetail();
                orderdetailbll.Add(orderDetail);
            }
            order.Total = GetTotal();
            EmptyCart();
            return(order.OrderId);
        }