public IActionResult Checkout(ViewCartModel model) { var checkout = new CheckoutViewModel { Subtotal = model.Subtotal }; return(View(checkout)); }
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)); }
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); }
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); } }
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)); }
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); }