示例#1
0
文件: TestUtil.cs 项目: xuanvu/Verde
 /// <summary>
 /// Add some albums to the specified user's cart.
 /// </summary>
 public static MvcMusicStore.Models.ShoppingCart AddItemsToCart(string userName, IEnumerable<Album> albums)
 {
     var cart = new MvcMusicStore.Models.ShoppingCart { ShoppingCartId = userName };
     cart.EmptyCart();
     foreach (var album in albums)
         cart.AddToCart(album);
     return cart;
 }
示例#2
0
 public static ShoppingCart FindShoppingCart()
 {
     var shoppingCartId = GetShoppingCartId(HttpContext.Current);
     var shoppingCart = MvcApplication.CurrentSession.Load<ShoppingCart>(shoppingCartId);
     if(shoppingCart == null)
     {
         shoppingCart = new ShoppingCart {Id = shoppingCartId};
         MvcApplication.CurrentSession.Store(shoppingCart);// in memory operation only
     }
     return shoppingCart;
 }
示例#3
0
        public static ShoppingCart GetCart(HttpContextBase context)
        {
            var ioc = new IoC();

            var cartAppService = ioc.Kernel.Get<ICartAppService>();
            var orderDetailAppService = ioc.Kernel.Get<IOrderDetailAppService>();
            var orderAppService = ioc.Kernel.Get<IOrderAppService>();

            var cart = new ShoppingCart(cartAppService, orderDetailAppService, orderAppService);
            cart.ShoppingCartId = cart.GetCartId(context);
            return cart;
        }
示例#4
0
 public static ShoppingCart GetCart(ICartIdProvider idProvider)
 {
     var cart = new ShoppingCart();
     cart.shoppingCartId = idProvider.GetCartId();
     return cart;
 }
示例#5
0
 public static ShoppingCart GetCart(HttpContextBase context)
 {
     var cart = new ShoppingCart();
     cart.ShoppingCartId = cart.GetCartId(context);
     return cart;
 }
示例#6
0
 public static ShoppingCart GetCart(MusicStoreEntities db, HttpContext context)
 {
     var cart = new ShoppingCart(db);
     cart.ShoppingCartId = cart.GetCartId(context);
     return cart;
 }
示例#7
0
 public static ShoppingCart GetCart(HttpContextBase httpContext, IMusicStoreContext storeContext)
 {
     var cart = new ShoppingCart(storeContext);
     cart.shoppingCartId = cart.GetCartId(httpContext);
     return cart;
 }