//
        // GET: /ShoppingCart/

        public ActionResult Index()
        {
            var telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();

            var cart = ShoppingCart.GetCart(storeDB, this.HttpContext);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal()
            };

            foreach (var item in viewModel.CartItems)
            {
                Trace.Write("Cart item: " + item.AlbumId);
            }
            
            //Sample Trace Telemetry
            TraceTelemetry sampleTelemetry = new TraceTelemetry();
            sampleTelemetry.Message = "Normal response- Database";
            sampleTelemetry.SeverityLevel = SeverityLevel.Information;
            telemetryClient.TrackTrace(sampleTelemetry);

            // Return the view
            return View(viewModel);
        }
コード例 #2
0
 public ActionResult Index()
 {
     var cart = ShoppingCart.GetCart(this.HttpContext);
     var viewModel = new ShoppingCartViewModel
     {
         CartItems = cart.GetCartItems(),
         CartTotal = cart.GetTotal()
     };
     return View(viewModel);
 }
コード例 #3
0
        public ActionResult Index()
        {
            ShoppingCart shoppingCart = ShoppingCart.GetCart(HttpContext);
            ShoppingCartViewModel viewModel = new ShoppingCartViewModel
            {
                Carts = shoppingCart.GetCarts().ToList(),
                Total = shoppingCart.GetTotal()
            };

            return View(viewModel);
        }
コード例 #4
0
        //
        // GET: /ShoppingCart/
        public ActionResult Index()
        {
            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = _cart.GetCartItems(_cartid),
                CartTotal = _cart.GetTotal(_cartid)
            };

            // Return the view
            return View(viewModel);
        }
コード例 #5
0
        // GET: /ShoppingCart/
        public async Task<ActionResult> Index()
        {
            var cart = ShoppingCart.GetCart(_storeContext, this);

            var viewModel = new ShoppingCartViewModel
            {
                CartItems = await cart.GetCartItems().ToListAsync(),
                CartTotal = await cart.GetTotal()
            };

            return View(viewModel);
        }
コード例 #6
0
        // GET: ShoppingCart
        public ActionResult Index()
        {
            var cart = ShoppingCart.GetCart(this.HttpContext);

            var viewModel = new ShoppingCartViewModel
            {
                CartElements = cart.GetCartElements(),
                CartTotal = cart.GetTotal(),
                UserName=User.Identity.GetUserName()
            };
            return View(viewModel);
        }
コード例 #7
0
        //
        // GET: /ShoppingCart/

        public ActionResult Index() {
            var cart = ShoppingCart.GetCart(storeDB, this.HttpContext);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal()
            };

            // Return the view
            return View(viewModel);
        }
コード例 #8
0
        //
        // GET: /ShoppingCart/

        public ActionResult Index()
        {
            var cart = ShoppingCartFinder.FindShoppingCart();

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.Lines,
                CartTotal = cart.Lines.Count
            };

            // Return the view
            return View(viewModel);
        }
コード例 #9
0
        //
        // GET: /ShoppingCart/

        public ActionResult Index()
        {
            var cart = ShoppingCart.GetCart(this.idProvider);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal()
            };

            // Return the view
            return View(viewModel);
        }
コード例 #10
0
        // GET: ShoppingCart
        public ActionResult Index()
        {
            ShoppingCart.Models.ShoppingCart shoppingCart = new ShoppingCart.Models.ShoppingCart();
            var cart = shoppingCart.GetCart(this.HttpContext.Session.SessionID);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.CartItems,
                //CartTotal = cart.GetTotal()
            };
            // Return the view
            return View(viewModel);
        }
コード例 #11
0
ファイル: CartStart.cs プロジェクト: dungtruong/NC-Projects
        public async Task <IViewComponentResult> InvokeAsync()
        {
            await _shoppingCart.GetShoppingCartItemsAsync();

            var shoppingCartCountTotal = await _shoppingCart.GetCartCountAndTotalAmmountAsync();

            var shoppingCartViewModel = new ShoppingCartViewModel
            {
                ShoppingCart           = _shoppingCart,
                ShoppingCartItemsTotal = shoppingCartCountTotal.ItemCount,
                ShoppingCartTotal      = shoppingCartCountTotal.TotalAmmount,
            };

            return(View(shoppingCartViewModel));
        }
コード例 #12
0
        //list all items in shopping cart
        public ViewResult Index()
        {
            var items = _shoppingCart.GetShoppingCartItems();

            _shoppingCart.ShoppingCartItems = items;

            var shoppingCartViewModel = new ShoppingCartViewModel
            {
                ShoppingCart            = _shoppingCart,
                ShoppingCartTotalAmount = _shoppingCart.GetShoppingCartTotalAmount(),
                ShoppingCartTotalPrice  = _shoppingCart.GetShoppingCartTotalPrice()
            };

            return(View(shoppingCartViewModel));
        }
コード例 #13
0
        // GET: ShoppingCart
        public ActionResult Index()
        {
            ShoppingCart.Models.ShoppingCart shoppingCart = new ShoppingCart.Models.ShoppingCart();
            var cart = shoppingCart.GetCart(this.HttpContext.Session.SessionID);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.CartItems,
                //CartTotal = cart.GetTotal()
            };

            // Return the view
            return(View(viewModel));
        }
コード例 #14
0
        // GET: ShoppingCart
        public ActionResult Index()
        {
            // get current cart
            var cart = ShoppingCart.GetCart(this.HttpContext);

            // set up viewmodel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetItems(),
                CartTotal = cart.GetTotal()
            };

            // pass populated Cart viewmodel to the view
            return(View(viewModel));
        }
コード例 #15
0
        public void PatchInternalError()
        {
            _shoppingCartService.Setup(s => s.UpdateStatus(It.IsAny <long>(), It.IsAny <ShoppingCartStatus>())).Throws(new Exception());;

            var shoppingCart = new ShoppingCartViewModel();

            var result = _controller.Patch(shoppingCart);

            Assert.NotNull(result);
            Assert.IsType <StatusCodeResult>(result.Result);

            var httpObjResult = result.Result as StatusCodeResult;

            Assert.True(httpObjResult.StatusCode == 500);
        }
コード例 #16
0
        public IActionResult Index()
        {
            var items = ShoppingCart.GetShoppingCartItems();

            ShoppingCart.ShoppingCartItems = items;
            var total = ShoppingCart.GetShoppingCartTotal();
            var scVM  = new ShoppingCartViewModel
            {
                ShoppingCart      = ShoppingCart,
                ShoppingCartTotal = total,
                Taxes             = total * 0.01
            };

            return(View(scVM));
        }
コード例 #17
0
        // GET: /ShoppingCart/
        public async Task<IActionResult> Index()
        {
            var cartId = _shoppingCartService.GetCartId(this.HttpContext);
            var cartItems = await _shoppingCartService.GetCurrentCart(cartId);
            var totalAmout = cartItems.Sum(c => c.Quantity * c.Movie.Price);
    
            var viewMovel = new ShoppingCartViewModel
            {
                CartItems = cartItems,
                ShoppingCartTotal = totalAmout
            };

            return View(viewMovel);
            
        }
コード例 #18
0
        // GET: Admin/ShoppingCart
        public ActionResult Index(int?p)
        {
            int limit = 20;
            var count = _shoppingCartService.GetCount();

            var Paging = CalcPaging(limit, p, count);

            var viewModel = new ShoppingCartViewModel
            {
                Paging        = Paging,
                shoppingCarts = _shoppingCartService.GetList(limit, Paging.Page),
            };

            return(View(viewModel));
        }
コード例 #19
0
        public IViewComponentResult Invoke()
        {
            var cartItems = _shoppingCart.GetShoppingCartItems();

            _shoppingCart.ShoppingCartItems = cartItems;

            var shoppingCartView = new ShoppingCartViewModel()
            {
                ShoppingCart      = _shoppingCart,
                ShoppingCartTotal = _shoppingCart.GetTotalPrice(),
                NumberOfItems     = _shoppingCart.GetNumberOfItems()
            };

            return(View(shoppingCartView));
        }
コード例 #20
0
        public IViewComponentResult Invoke()
        {
            var items = _shoppingCart.GetShoppingCartItems();

            _shoppingCart.ShoppingCartItems = items;

            var shoppingCartViewModel = new ShoppingCartViewModel
            {
                ShoppingCart           = _shoppingCart,
                ShoppingCartPriceTotal = _shoppingCart.GetShoppingCartPriceTotal(),
                ShoppingCartItemTotal  = _shoppingCart.GetShoppingCartItemTotal()
            };

            return(View(shoppingCartViewModel));
        }
コード例 #21
0
        //
        // GET: /Checkout/AddressAndPayment
        public ActionResult AddressAndPayment()
        {
            var cart = ShoppingCart.GetCart(this.HttpContext);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal()
            };

            ViewBag.Cart = viewModel;

            return(View());
        }
コード例 #22
0
        public ViewResult Index()
        {
            var Items = _shoppingCart.GetShoppingCartItems();

            //assigning the List Prop to items, before passing to the viewModel
            _shoppingCart.ShoppingCartItems = Items;

            var shoppingCartViewModel = new ShoppingCartViewModel
            {
                ShoppingCart      = _shoppingCart,
                ShoppingCartTotal = _shoppingCart.GetShoppingCartTotal()
            };

            return(View(shoppingCartViewModel));
        }
コード例 #23
0
        public ViewResult Index()
        {
            var items = _shoppingCart.GetShoppingCartItems();

            _shoppingCart.ShoppingCartItems = items;
            ViewBag.Title = "ASP.NET Drinks - Shopping Cart";

            var sCVM = new ShoppingCartViewModel
            {
                ShoppingCart      = _shoppingCart,
                ShoppingCartTotal = _shoppingCart.GetShoppingCartTotal()
            };

            return(View(sCVM));
        }
コード例 #24
0
        public Task <IViewComponentResult> InvokeAsync()
        {
            List <CartItem> list = GetCartAsync();

            if (list == null)
            {
                list = new List <CartItem>();
            }
            ShoppingCartViewModel giohang = new ShoppingCartViewModel()
            {
                Items = list
            };

            return(Task.FromResult <IViewComponentResult>(View(giohang)));
        }
コード例 #25
0
        public IActionResult Index(string ShoppingCartId)
        {
            Console.WriteLine("ShoppingCart Index, Id: " + ShoppingCartId);
            var cart = ShoppingCartRepository.GetCart(storeDB);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetCartItems(ShoppingCartId),
                CartTotal = cart.GetTotal(ShoppingCartId)
            };

            // Return the view
            return(Ok(viewModel));
        }
コード例 #26
0
        public IViewComponentResult Invoke()
        {
            var items = _shoppingCart.GetShoppingCartItems();

            _shoppingCart.ShoppingCartItems = items;
            var total = _shoppingCart.GetShoppingCartTotal();
            var shoppingCartViewModel = new ShoppingCartViewModel
            {
                ShoppingCart      = _shoppingCart,
                ShoppingCartTotal = total,
                Taxes             = total * 0.01
            };

            return(View(shoppingCartViewModel));
        }
コード例 #27
0
        public ShoppingCartViewModel ReturnCurrentCartViewModel()
        {
            var cart = ShoppingCart.GetCart(this.HttpContext);
            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems  = cart.GetCartItems(_context),
                SubTotal   = cart.GetSubtotal(_context),
                GST        = cart.GetTotalGST(_context),
                GrandTotal = cart.GetGrandTotal(_context),
                TotalCount = cart.GetTotalCount(_context)
            };

            return(viewModel);
        }
コード例 #28
0
        public ViewResult Index()
        {
            var items = _shoppingCart.GetShoppingCartItems();

            _shoppingCart.ShoppingCartItems = items;


            var sCVM = new ShoppingCartViewModel
            {
                ShoppingCart      = _shoppingCart,
                ShoppingCartTotal = _shoppingCart.GetShoppingCartTotal()
            };

            return(View(sCVM));
        }
コード例 #29
0
        /// <summary>
        /// ** this method is called by ASP.NET Core to render view component
        /// ** notice return type IViewComponentResult
        /// </summary>
        /// <returns></returns>
        public IViewComponentResult Invoke()
        {
            var items = _shoppingCart.GetShoppingCartItems();

            _shoppingCart.ShoppingCartItems = items;

            var shoppingCartViewModel = new ShoppingCartViewModel
            {
                ShoppingCart      = _shoppingCart,
                ShoppingCartTotal = _shoppingCart.GetShoppingCartTotal()
            };

            //*** View name needs to be Default.cshtml
            return(View(shoppingCartViewModel));
        }
コード例 #30
0
ファイル: ShopController.cs プロジェクト: nalaka526/SCApp
        private ShoppingCartViewModel GetShoppingCart()
        {
            ShoppingCartViewModel cart;

            if (Session["cart"] == null)
            {
                cart = new ShoppingCartViewModel();
            }
            else
            {
                cart = (ShoppingCartViewModel)Session["cart"];
            }

            return(cart);
        }
コード例 #31
0
        // GET: ShoppingCart
        public ActionResult Index()
        {
            // Get current cart
            var cart = ShoppingCart.GetCart(this.HttpContext);

            // set up ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal()
            };

            //Pass the cart to the index view
            return(View(viewModel));
        }
コード例 #32
0
        public ActionResult Index()
        {
            var products = storeDB.Products.Where(x => x.Status == true).ToList();
            var cart     = ShoppingCart.GetCart(this.HttpContext);

            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal(),
            };

            viewModel.Products = products;

            return(View(viewModel));
        }
コード例 #33
0
        public IActionResult Index()
        {
            var itens = _shoppingCart.GetShoppingCartItem();

            _shoppingCart.ShoppingCartItems = itens;

            var shoppingCartViewModel = new ShoppingCartViewModel()
            {
                ShoppingCart           = _shoppingCart,
                TotalValueShoppingCart = _shoppingCart.GetShoppingCartTotalValue(),
                Categories             = _categoryRepository.FindAll()
            };

            return(View(shoppingCartViewModel));
        }
コード例 #34
0
        public IViewComponentResult Invoke()
        {
            var items = _shoppingCart.GetShoppingCartItems();

            //var items = new List<ShoppingCartItem> { new ShoppingCartItem(), new ShoppingCartItem() };
            _shoppingCart.ShoppingCartItems = items;

            var shoppingCartViewModel = new ShoppingCartViewModel
            {
                ShoppingCart      = _shoppingCart,
                ShoppingCartTotal = _shoppingCart.GetShoppingCartTotal()
            };

            return(View(shoppingCartViewModel));
        }
コード例 #35
0
        public async Task <IActionResult> Clear()
        {
            string cartId = this.HttpContext.Session.Get <string>(base.AppSettings.ShoppingCartSessionKey);

            if (cartId == null)
            {
                return(BadRequest("Shopping cart is not initialized!"));
            }

            await this.cartManager.ClearShoppingCartAsync(cartId);

            ShoppingCartViewModel cartModel = new ShoppingCartViewModel();

            return(Json(cartModel));
        }
コード例 #36
0
        public IActionResult AddCouponCode(string couponCode)
        {
            // Adds the coupon code to the shopping cart
            if ((couponCode == "") || !shoppingService.AddCouponCode(couponCode))
            {
                // Adds an error message to the model state if the entered coupon code is not valid
                ModelState.AddModelError("CouponCodeError", "The entered coupon code is not valid.");
            }

            // Initializes the shopping cart model
            ShoppingCartViewModel model = new ShoppingCartViewModel(shoppingService.GetCurrentShoppingCart());

            // Displays the shopping cart
            return(View("ShoppingCart", model));
        }
コード例 #37
0
        //ProductContext _productContext = new ProductContext();
        //
        // GET: /ShoppingCart/
        public ActionResult Index()
        {
            var cart = ShoppingCart.GetCart(this.HttpContext);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems             = cart.GetCartItems(),
                CartTotal             = cart.GetTotal() + cart.GetTotalShippingCost(),
                CartTotalShippingCost = cart.GetTotalShippingCost()
            };

            // Return the view
            return(View(viewModel));
        }
コード例 #38
0
        public async Task <IActionResult> AddToCart(int productId)
        {
            var product = await this.productsData
                          .GetByIdQuery(productId)
                          .ProjectTo <ProductViewModel>()
                          .FirstOrDefaultAsync();

            if (product == null)
            {
                this.TempData.AddErrorMessage("No such product");
                return(this.RedirectToHome());
            }

            var cart = this.HttpContext.Session
                       .GetObjectFromJson <ShoppingCartViewModel>(WebConstants.ShoppingCartSessionKey);

            if (cart == null)
            {
                cart = new ShoppingCartViewModel();

                var user = await this.userManager.GetUserAsync(this.User);

                if (user != null)
                {
                    cart.UserId = user.Id;
                }
            }

            if (cart.CartItems.All(item => item.ProductId != productId))
            {
                cart.CartItems.Add(new CartItem
                {
                    ProductId = productId,
                    Product   = product,
                    Quantity  = 1
                });
            }
            else
            {
                this.TempData.AddInfoMessage("Item is already in the cart");
                return(this.RedirectBack());
            }

            this.HttpContext.Session.SetObjectAsJson(WebConstants.ShoppingCartSessionKey, cart);

            this.TempData.AddSuccessMessage("Item added to cart");
            return(this.RedirectToAction("Products", "Categories", new { area = "Products", id = product.CategoryId }));
        }
コード例 #39
0
        private ShoppingCartViewModel AddCartPro(string id, int soluong)
        {
            var obj  = db.Products.First(u => u.id.Equals(id));
            int flag = -1;
            int gia  = obj.proPrice_sale.Value;

            ShoppingCartViewModel shoppCart;
            var cartGet = ClassExten.GetCokiesCart();

            if (cartGet == null)
            {
                shoppCart = new ShoppingCartViewModel();
                ClassExten.CreateCookiesCart(string.Empty);
            }
            else
            {
                shoppCart = cartGet;
            }
            if (GetCartItem(shoppCart, obj.id) == flag)
            {
                var cartItem = new Cart
                {
                    productId   = obj.id,
                    productName = obj.pro_name,
                    productImg  = obj.proAvata,
                    price       = gia,
                    count       = soluong,
                    total       = soluong * gia,
                    key         = obj.pro_key
                };
                shoppCart.CartItems.Add(cartItem);
            }
            else
            {
                flag = GetCartItem(shoppCart, obj.id);
                shoppCart.CartItems[flag].count += soluong;
                shoppCart.CartItems[flag].total  = shoppCart.CartItems[flag].price * shoppCart.CartItems[flag].count;
            }


            for (int k = 0; k < shoppCart.CartItems.Count; k++)
            {
                cartTotal += shoppCart.CartItems[k].total;
            }
            shoppCart.CartTotal = cartTotal;
            ClassExten.UpdateCookiesCart(JsonConvert.SerializeObject(shoppCart));
            return(shoppCart);
        }
コード例 #40
0
        public ActionResult AddToCart(int qty, int bookID)
        {
            //Create and Empty shopping cart (local version)
            Dictionary <int, ShoppingCartViewModel> shoppingCart = null;

            //check the session variable that represents a cart with items in it
            //if the global cart has "stuff" in it, then we will assign its value to our local version.
            if (Session["cart"] != null)
            {
                shoppingCart = (Dictionary <int, ShoppingCartViewModel>)Session["cart"];
            }
            //else - create an empty local version
            else
            {
                shoppingCart = new Dictionary <int, ShoppingCartViewModel>();
            }

            //Get the product being added (using the id)
            Book product = db.Books.Where(b => b.BookID == bookID).FirstOrDefault();

            //if the product is null - redirect to the books index
            if (product == null)
            {
                return(RedirectToAction("Index"));
            }
            //else - Add the product and quantity to the cart
            else
            {
                //Create the ShoppingCartViewModel object
                ShoppingCartViewModel item = new ShoppingCartViewModel(qty, product);

                //if the shoppingcart already has a product with that id, increase the qty (local)
                if (shoppingCart.ContainsKey(product.BookID))
                {
                    shoppingCart[product.BookID].Qty += qty;
                }
                //else add it to the cart (local)
                else
                {
                    shoppingCart.Add(product.BookID, item);
                }

                //update the global cart (session) with the NEW information
                Session["cart"] = shoppingCart;
            }
            //send the user to the shopping cart landing page (index)
            return(RedirectToAction("Index", "ShoppingCart"));
        }
コード例 #41
0
        public ActionResult Index()
        {
            var products = new List<Product>();
            for (int i = 0; i < 10; i++)
            {
                products.Add(new Product { Title = "Product " + i, Price = 1.13M * i });
            }

            var model = new ShoppingCartViewModel
            {
                Products = products,
                CartTotal = products.Sum(p => p.Price),
                Message = "Thanks for your business!"
            };

            return View(model);
        }
コード例 #42
0
        //
        // GET: /ShoppingCart/
        public ActionResult Index()
        {
            var cart = ShoppingCart.GetCart(this.HttpContext);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {

                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal()
            };

            ViewBag.Products = storeDB.Products.Where(p => p.Rating.Equals(5) || p.Rating.Equals(4));
            int productCount = storeDB.Products.Where(p => p.Rating.Equals(5) || p.Rating.Equals(4)).Count();
            Random rnd = new Random();
            // Return the view
            return View(viewModel);
        }
コード例 #43
0
ファイル: ShoppingCartController.cs プロジェクト: ravikp/Blog
        // AF - we have to add this b/c our cart item doesn't show up right away, but we can show the album we just added
        public ActionResult AddedItemToCart(int id)
        {
            var cart = ShoppingCart.GetCart(this.HttpContext);

            // Retrieve the album from the database
            var addedAlbum = storeDB.Albums
                .Single(album => album.AlbumId == id);

            // Set up our ViewModel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = new System.Collections.Generic.List<Cart>(),
                CartTotal = cart.GetTotal() + addedAlbum.Price
            };

            viewModel.CartItems.Add(new Cart { Album = addedAlbum, AlbumId = addedAlbum.AlbumId, Count = 1 });

            return View(viewModel);
        }
コード例 #44
0
        public ActionResult Update(ShoppingCartViewModel model)
        {
            ShoppingCart cart = GetOrCreateCart();
            foreach (ShoppingCartItem item in cart.ShoppingCartItems.ToList())
            {
                ShoppingCartItemViewModel updatedItem = model.Items.FirstOrDefault(i => i.Id == item.Id);
                if (updatedItem == null) continue;
                if (updatedItem.Quantity <= 0)
                {
                    db.ShoppingCartItems.Remove(item);
                    db.SaveChanges();
                }
                else if (updatedItem.Quantity != item.Quantity)
                {
                    item.Quantity = updatedItem.Quantity;
                    db.SaveChanges();
                }
            }

            return RedirectToAction("Index");
        }
コード例 #45
0
        public PartialViewResult Preview()
        {
            ShoppingCart cart = GetOrCreateCart();

            var model = new ShoppingCartViewModel();
            model.Items = Mapper.Map<List<ShoppingCartItemViewModel>>(cart.ShoppingCartItems);

            return PartialView("_Preview", model);
        }
コード例 #46
0
        public ActionResult Index()
        {
            ShoppingCart cart = GetOrCreateCart();

            var model = new ShoppingCartViewModel();
            model.Items = Mapper.Map<List<ShoppingCartItemViewModel>>(cart.ShoppingCartItems);

            return View(model);
        }
コード例 #47
0
        public ActionResult ShoppingCart()
        {
            ShoppingCartViewModel cart;
            if (Request.Cookies[UserIdCart] != null)
            {
                cart = this.Mapper.Map<ShoppingCartViewModel>(this.shoppingService.GetByUserId(Request.Cookies[UserIdCart].Value));
            }
            else
            {
                cart = new ShoppingCartViewModel { ProductsCount = 0 };
            }

            return PartialView("_ShoppingCart", cart);
        }