Beispiel #1
0
        public ActionResult Checkout(string cart)
        {
            ApplicationDbContext db = new ApplicationDbContext();



            List <OrderDetail> orderDetails = JsonConvert.DeserializeObject <List <OrderDetail> >(cart);

            List <ShopingCartViewModel> viewModel = new List <ShopingCartViewModel>(); //

            decimal totalPrice = 0;

            foreach (var item in orderDetails)
            {
                Product currentProduct = db.Product.Find(item.ProductId); //current Product är denna product som vi klickar på.

                ShopingCartViewModel currentCartItem = new ShopingCartViewModel();
                currentCartItem.Product    = currentProduct;
                currentCartItem.Amount     = item.Amount;
                currentCartItem.TotalPrice = item.Amount * currentProduct.Price;

                totalPrice += currentCartItem.TotalPrice;

                viewModel.Add(currentCartItem);
            }

            return(View(viewModel));
        }
Beispiel #2
0
        // GET: ShoppingCart
        public ActionResult Index()
        {
            ApplicationUserManager userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
            ApplicationUser        user        = userManager.FindByEmail(User.Identity.Name);

            if (user != null)
            {
                var rolle = userManager.GetRoles(user.Id);
                if (rolle.Count != 0)
                {
                    ViewBag.view = "visibility:visible";
                }
                else
                {
                    ViewBag.view = "visibility:hidden";
                }
            }
            else
            {
                ViewBag.view = "visibility:hidden";
            }
            var cart      = ShoppingCart.GetCart(this.HttpContext);
            var viewModel = new ShopingCartViewModel()
            {
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal()
            };

            return(View(viewModel));
        }
        public IActionResult Cart()
        {
            var items = _shopingCartService.GetShoppingCartItems();

            _shopingCartService.ShoppingCartItems = items;

            var sCVM = new ShopingCartViewModel()
            {
                ShopingCart       = _shopingCartService,
                ShoppingCartTotal = _shopingCartService.GetShopingCartTotal()
            };

            return(View(sCVM));
        }
        // GET: /<controller>/
        public IActionResult Index()
        {
            List <ShopingCardItem> shopingCartItems = new List <ShopingCardItem>();

            shopingCartItems = _shopingCart.getShopingCardItems();
            _shopingCart.ShoppingCardItems = shopingCartItems;

            ShopingCartViewModel shopingcardviewmodel = new ShopingCartViewModel();

            shopingcardviewmodel.ShopingCard      = _shopingCart;
            shopingcardviewmodel.ShopingCardTotal = _shopingCart.GetShopingCardTotal();

            return(View(shopingcardviewmodel));
        }
        // GET: ShopingCart
        public ViewResult Index()
        {
            //Getting Shoping Cart Items
            var items = _shopingCart.GetShopingCartItems();

            _shopingCart.ShopingCartItems = items;
            //Setting Shoping Cart View Model
            var shopingCartVM = new ShopingCartViewModel
            {
                ShopingCart      = _shopingCart,
                ShopingCartTotal = _shopingCart.GetShopingCartTotal()
            };

            return(View(shopingCartVM));
        }
        public IViewComponentResult Invoke()
        {
            //List<ShopingCardItem> listdumy = new List<ShopingCardItem>();
            //ShopingCardItem shop = new ShopingCardItem();
            //listdumy.Add(shop);
            //ShopingCardItem shop1 = new ShopingCardItem();
            //listdumy.Add(shop1);


            var shoppingcarditem = _shopingCard.getShopingCardItems();

            //var shoppingcarditem = listdumy;
            _shopingCard.ShoppingCardItems = shoppingcarditem;

            ShopingCartViewModel shopingCardViewModel = new ShopingCartViewModel();

            shopingCardViewModel.ShopingCard = _shopingCard;
            decimal shopingCardtotal = _shopingCard.GetShopingCardTotal();

            shopingCardViewModel.ShopingCardTotal = shopingCardtotal;
            //shopingCardViewModel.ShopingCardTotal = 0;
            return(View(shopingCardViewModel));
        }
        public void shopping_cartTest()
        {
            ShopingCartViewModel model = new ShopingCartViewModel();
            var service = new Shopping_Cart_Service();

            model.ReserveItem = "手部精緻保養,足部精緻保養";
            var get_service_price_model = service.GetService(model.ReserveItem);

            var user_name = "*****@*****.**";
            var Account   = new AccountDetailService();

            var viewmodel = Account.get_account_detail(user_name);
            var _Coupon   = service.GetCoupon(viewmodel.Cust_id);

            var get_designer_model = service.GetDesigners();

            var get_session = service.Get_Session_list();

            Assert.IsNotNull(get_service_price_model);
            Assert.IsNotNull(viewmodel);
            Assert.IsNotNull(_Coupon);
            Assert.IsNotNull(get_designer_model);
            Assert.IsNotNull(get_session);
        }