public IActionResult Checkout(ViewCartModel model)
        {
            var checkout = new CheckoutViewModel
            {
                Subtotal = model.Subtotal
            };

            return(View(checkout));
        }
Ejemplo n.º 2
0
        public ActionResult ViewCart()
        {
            ViewCartModel vcm    = new ViewCartModel();
            ViewCartDTO   vcdto  = new ViewCartDTO();
            Guid          userId = new Guid(Session["UserID"].ToString());

            vcdto = cdc.viewCart(userId);
            vcm   = cartMapper.Map <ViewCartDTO, ViewCartModel>(vcdto);
            return(View(vcm));
        }
Ejemplo n.º 3
0
        public static int GetGrandTotal(int userId)
        {
            int         total = 0;
            List <Cart> c     = CartRepository.GetAllCarts(userId);

            foreach (var item in c)
            {
                ViewCartModel viewCart = CartRepository.GetAllCartProducts(item);
                total = total + viewCart.Subtotal;
            }
            return(total);
        }
Ejemplo n.º 4
0
        public async Task <IEnumerable <Cart> > ViewCart(ViewCartModel model)
        {
            const string query = @"select Name, Price, Qty, Cart.ProductId from Cart
join Products on Products.ProductId = Cart.ProductId";

            using (var connection = new SqlConnection(_connectionstring))
            {
                var orderDetail = await connection.QueryAsync <Cart>(query, model);

                return(orderDetail);
            }
        }
Ejemplo n.º 5
0
        public static List <ViewCartModel> GetAllCartProducts(int userId)
        {
            List <Cart> c = CartRepository.GetAllCarts(userId);

            List <ViewCartModel> vc = new List <ViewCartModel>();

            foreach (var item in c)
            {
                ViewCartModel viewCart = CartRepository.GetAllCartProducts(item);
                vc.Add(viewCart);
            }
            return(vc);
        }
        public async Task <IActionResult> ViewCart()
        {
            var model = new ViewCartModel();
            var cart  = await _productrepository.ViewCart(model);

            model.Cart = cart.Select(products => new Cart()
            {
                Name = products.Name, Price = products.Price, Qty = products.Qty, ProductId = products.ProductId
            })
                         .ToList();

            return(View(model));
        }
Ejemplo n.º 7
0
        public static ViewCartModel GetAllCartProducts(Cart item)
        {
            ViewCartModel vc = (from a in db.Products where a.Id == item.ProductId select
                                new ViewCartModel()
            {
                ProductID = a.Id,
                ProductName = a.Name,
                ProductPrice = a.Price,
                Quantity = item.Quantity,
                Subtotal = item.Quantity * a.Price
            }).FirstOrDefault();

            return(vc);
        }