public static string GetJsonShoppingCart() { Hashtable list = null; try { list = (Hashtable)HttpContext.Current.Session["SopiingCart"]; } catch { } if (list == null) { list = new Hashtable(); HttpContext.Current.Session["SopiingCart"] = list; } var viewModel = new CartListViewModel(); viewModel.Count = list.Count; viewModel.Products = new List <CartItemViewModel>(); foreach (DictionaryEntry it in list) { viewModel.Products.Add((CartItemViewModel)it.Value); } return(JsonConvert.SerializeObject(viewModel)); }
/// <summary> /// Gets the current users carts /// </summary> /// <param name="customerId">Current user id</param> /// <returns>A list of the users carts</returns> public CartListViewModel GetUserCartList(Guid customerId) { CartListViewModel cartList = new CartListViewModel(); List <CartInfoViewModel> carts = new List <CartInfoViewModel>(); Customer customer = _repo.GetCustomerById(customerId); if (customer == null) { return(null); } List <Order> customerCarts = _repo.GetCartsByCustomerId(customer.CustomerID); foreach (Order cart in customerCarts) { List <OrderLineDetails> orderLineDetails = _repo.GetOrderLineListByCart(cart); cart.ProductsInOrder = orderLineDetails; carts.Add(_mapper.ConvertOrderToCartInfoViewModel(cart)); } cartList.CurrentCarts = carts; return(cartList); }
/// <summary> /// Gets a list of a users completed orders /// </summary> /// <param name="customerId">Current user</param> /// <returns>List of customers orders</returns> public CartListViewModel GetUserPastOrders(Guid customerId) { CartListViewModel orderList = new CartListViewModel(); List <CartInfoViewModel> orders = new List <CartInfoViewModel>(); Customer customer = _repo.GetCustomerById(customerId); if (customer == null) { return(null); } List <Order> customerOrders = _repo.GetOrdersByCustomerId(customer.CustomerID); foreach (Order order in customerOrders) { List <OrderLineDetails> orderLineDetails = _repo.GetOrderLineListByCart(order); order.ProductsInOrder = orderLineDetails; orders.Add(_mapper.ConvertOrderToCartInfoViewModel(order)); } orderList.CurrentCarts = orders; return(orderList); }
/// <summary> /// Gets a list of a stores completed orders /// </summary> /// <param name="StoreId">Store id we want to look at</param> /// <returns>A list of orders by store id</returns> public CartListViewModel GetStorePastOrders(Guid StoreId) { CartListViewModel orderList = new CartListViewModel(); List <CartInfoViewModel> orders = new List <CartInfoViewModel>(); StoreLocation store = _repo.GetStoreById(StoreId); if (store == null) { return(null); } List <Order> storeOrders = _repo.GetOrdersByStoreId(store.StoreLocationId); foreach (Order order in storeOrders) { List <OrderLineDetails> orderLineDetails = _repo.GetOrderLineListByCart(order); order.ProductsInOrder = orderLineDetails; orders.Add(_mapper.ConvertOrderToCartInfoViewModel(order)); } orderList.CurrentCarts = orders; return(orderList); }
public IActionResult GetCartList() { List <CartItem> cart = cartServices.GetCartList(UserName); CartListViewModel viewModel = new CartListViewModel(); if (cart != null) { viewModel.CartItems = cart .Select(x => new CartViewModel() { Id = x.Id, ImageAddress = x.Product.PictureAddress, Price = x.Product.Price, Quantity = x.Quantity, Title = x.Product.Title }).ToList(); viewModel.TotalPrice = cart.Sum(x => x.Quantity * x.Product.Price); } else { viewModel = new CartListViewModel() { CartItems = new List <CartViewModel>(), TotalPrice = 0 }; } return(Json(viewModel)); }
public IActionResult CartList() { var cartList = new CartListViewModel { cart = GetCart() }; return(View(cartList)); }
public ViewViewComponentResult Invoke() { var model = new CartListViewModel() { Cart = _cartSessionHelper.GetCart(CartController.CartKey) }; return(View(model)); }
public ViewViewComponentResult Invoke() { var model = new CartListViewModel { Cart = _cartSessionHelper.GetCart("cart") }; return(View(model)); }
public IActionResult Index() { var model = new CartListViewModel { Cart = cartSessionHelper.GetCart(key: "cart") }; return(View(model)); }
public IActionResult Checkout() { var model = new CartListViewModel { Cart = _cartSessionHelper.GetCart("cart") }; return(View(model)); }
//burada Invoke diyip modeli içine basıyorum public ViewViewComponentResult Invoke() { var model = new CartListViewModel { Cart = _cartSessionService.GetCart() }; return(View(model)); }
public IActionResult Index() { CartListViewModel cartListViewModel = new CartListViewModel() { Cart = _cartSessionHelper.GetCart("cart") }; return(View(cartListViewModel)); }
public IActionResult Index() { var cart = _cartSessionHelper.GetCart(CartKey); var model = new CartListViewModel() { Cart = cart }; return(View(model)); }
public IActionResult List() { var cart = _sessionService.GetCart(); CartListViewModel model = new CartListViewModel() { Cart = cart, }; return(View(model)); }
public ActionResult List() { var cart = _cartSessionService.GetCart(); CartListViewModel cartListViewModel = new CartListViewModel { Cart = cart }; return(View(cartListViewModel)); }
public ActionResult List() { var cart = _cartSessionService.GetCart(); // CartLİstViewMOdel e ihtiyacım var CartListViewModel model = new CartListViewModel { Cart = cart }; return(View(model)); }
public ActionResult Index() { var viewModel = new CartListViewModel(); var list = GetShoppingCart(); //viewModel.Products = GetSopiingCart(); var pricmodel = _productSevice.GetAttribute("Price"); var Guaranteemodel = _productSevice.GetAttribute("Guarantee"); viewModel.Count = list.Count; viewModel.Products = new List <CartItemViewModel>(); foreach (DictionaryEntry it in list) { CartItemViewModel item = (CartItemViewModel)it.Value; var pr = _productSevice.Get(item.Id); if (pr != null) { viewModel.Products.Add(item); item.Image = pr.Image; item.link = AppHelpers.ProductUrls(pr.Category_Id, pr.Slug); var Guarante = _productSevice.GetAttributeValue(item.Id, Guaranteemodel.Id); if (Guarante != null) { item.Guarantee = Guarante.Value; } var price = _productSevice.GetAttributeValue(item.Id, pricmodel.Id); if (price != null) { try { int p = int.Parse(price.Value); item.Priceint = p; item.Price = p.ToString("N0").Replace(",", ".") + " VND"; viewModel.TotalMoney += p * item.Count; } catch { item.Price = "Liên hệ"; } } else { item.Price = "Liên hệ"; } } } return(View(viewModel)); }
public ActionResult SuccessPay() { int customerId = (int)Session["id"]; var ordereds = _orderedService.GetAll().Where(x => x.CustomerID == customerId).ToList(); CartListViewModel model = new CartListViewModel() { Ordereds = ordereds }; return(View(model)); }
public IActionResult ViewStorePastOrders(Guid StoreId) { CartListViewModel orderList = _logic.GetStorePastOrders(StoreId); if (orderList == null) { ModelState.AddModelError("Failure", "Store does not exist "); return(View(orderList)); } return(View(orderList)); }
public ActionResult Checkout() { if (Session["MovieList"] != null) { List <int> movieIdList = (List <int>)Session["MovieList"]; List <Movie> movieList = GetCartMovies(movieIdList); CartListViewModel displayedCart = new CartListViewModel(); return(View(ArrangeCart(movieList, displayedCart))); } return(RedirectToAction("Index", "Movies")); }
public async Task <ViewResult> Index() { cart.ListCartItems = await cart.GetCartItems(); var obj = new CartListViewModel { Cart = cart, SumCartItem = cart.SumCartItem() }; return(View(obj)); }
// GET: Checkout public ActionResult Index() { int id = (int)Session["id"]; var customer = _customerService.GetByIdUser(id); CartListViewModel model = new CartListViewModel() { Carts = (List <Cart>)Session["sepet"], Ordered = new Ordered(), Customer = customer }; return(View(model)); }
public ActionResult List() { if (_cartSessionService.GetCart().CartLines.Count <= 0) { return(RedirectToAction("Index", "Home")); } var model = new CartListViewModel { Cart = _cartSessionService.GetCart() }; return(View(model)); }
public JsonResult addVariant(Guid Id, int num) { var viewModel = new CartListViewModel(); var list = GetShoppingCart(); //viewModel.Products = GetSopiingCart(); if (!list.ContainsKey(Id.ToString())) { var product = _productSevice.Get(Id); if (product != null) { var a = new CartItemViewModel { name = product.Name, Count = num, Id = product.Id, }; list.Add(a.Id.ToString(), a); viewModel.Count = list.Count; viewModel.State = 1; } else { viewModel.State = 0; viewModel.Message = "Không tìm thấy sản phẩm!"; } } else { ((CartItemViewModel)list[Id.ToString()]).Count = num; viewModel.State = 1; } viewModel.Products = new List <CartItemViewModel>(); foreach (DictionaryEntry it in list) { viewModel.Products.Add((CartItemViewModel)it.Value); } return(Json(viewModel)); }
public ActionResult Checkout(CartListViewModel vwCartList) { int custIdExists = CheckCustExists(vwCartList.Email); if (custIdExists == 0) { ViewBag.Message = "Email is not registered, Please try again."; List <int> movieIdList = (List <int>)Session["MovieList"]; List <Movie> movieList = GetCartMovies(movieIdList); CartListViewModel displayedCart = new CartListViewModel(); return(View(ArrangeCart(movieList, displayedCart))); } else { return(RedirectToAction("Create", "Order", new { custId = custIdExists })); } }
public async Task <IActionResult> Index() { try { int?UserId = HttpContext.Session.GetInt32("UserId"); if (UserId != null && UserId != 0) { CartListViewModel data = await this._cartService.GetAllCartItem(UserId); if (data != null) { return(View(data)); } } return(RedirectToAction("LogIn", "Account")); } catch (Exception) { throw; } }
private object ArrangeCart(List <Movie> movieList, CartListViewModel displayedCart) { bool foundMovie = false; displayedCart.CartMovies.Add(new CartMovieViewModel() { Title = movieList[0].Title, Price = movieList[0].Price, CopyAmount = 1, TotalPriceOfMovie = movieList[0].Price, }); displayedCart.TotalPriceInCart = movieList[0].Price; for (int i = 1; i < movieList.Count; i++) { foreach (var item in displayedCart.CartMovies) { if (item.Title == movieList[i].Title && foundMovie == false) { item.CopyAmount += 1; item.TotalPriceOfMovie += item.Price; displayedCart.TotalPriceInCart += item.Price; foundMovie = true; } } if (foundMovie == false) { displayedCart.CartMovies.Add(new CartMovieViewModel() { Title = movieList[i].Title, Price = movieList[i].Price, CopyAmount = 1, TotalPriceOfMovie = movieList[i].Price }); displayedCart.TotalPriceInCart += movieList[i].Price; } foundMovie = false; } return(displayedCart); }
public async Task <IActionResult> Index() { string tempCartId = httpContextAccessor.HttpContext.Request.Cookies["tempCartId"]; List <TempCartItem> tempCarts = cartServices.GetTempCartList(tempCartId); if (tempCarts != null) { foreach (TempCartItem item in tempCarts) { cartServices.addToCart(UserName, item.Product.Id, item.Quantity); } await cartServices.DeleteTempCart(tempCartId); } List <CartItem> cart = cartServices.GetCartList(UserName); CartListViewModel viewModel = new CartListViewModel(); if (cart != null) { viewModel.CartItems = cart .Select(x => new CartViewModel() { Id = x.Id, ImageAddress = x.Product.PictureAddress, Price = x.Product.Price, Quantity = x.Quantity, Title = x.Product.Title }).ToList(); viewModel.TotalPrice = cart.Sum(x => x.Quantity * x.Product.Price); } else { viewModel = new CartListViewModel() { CartItems = new List <CartViewModel>(), TotalPrice = 0 }; } return(View(viewModel)); }
public JsonResult SetListProduct(CartListProductViewModel post) { var viewModel = new CartListViewModel(); var list = GetShoppingCart(); list.Clear(); foreach (var it in post.Products) { if (!list.ContainsKey(it.Id.ToString())) { var product = _productSevice.Get(it.Id); if (product != null) { var a = new CartItemViewModel { name = product.Name, Count = it.Count, Id = product.Id, }; list.Add(a.Id.ToString(), a); viewModel.Count = list.Count; } } } viewModel.State = 1; viewModel.Products = new List <CartItemViewModel>(); foreach (DictionaryEntry it in list) { viewModel.Products.Add((CartItemViewModel)it.Value); } return(Json(viewModel)); }
public JsonResult removeItem(Guid Id) { var viewModel = new CartListViewModel(); var list = GetShoppingCart(); //viewModel.Products = GetSopiingCart(); if (list.ContainsKey(Id.ToString())) { list.Remove(Id.ToString()); viewModel.Count = list.Count; viewModel.State = 1; } viewModel.Products = new List <CartItemViewModel>(); foreach (DictionaryEntry it in list) { viewModel.Products.Add((CartItemViewModel)it.Value); } return(Json(viewModel)); }