/// <summary> /// 清空购物车 /// </summary> public void ClearAll() { CartItems.Clear(); ShippingFee = 0; DiscountAmount = 0; CouponAmount = 0; }
public ActionResult Finish(FormCollection form) { if (CartItems.Count <= 0) { return(RedirectToAction("Index", "Cart")); } var order = new OrderSummary(); var member = db.MemberShips.First(m => m.Email == User.Identity.Name); order.OrderDate = DateTime.Now; if (TryUpdateModel(order)) { order.OrderDetails = GetOrderDetails(member); order.TotalTax = CartItems.Sum(item => item.TaxPrice); order.Shipping = member.Role == Role.Premium ? 0 : CartItems.Max(item => item.Shipping); order.TotalPrice = Math.Round(CartItems.Sum(item => item.Price) + order.TotalTax + order.Shipping, 2); order.Member = member; order.OrderStatus = db.OrderStatuses.First(os => os.Id == 1); StockOut(order); db.Orders.Add(order); db.SaveChanges(); CartItems.Clear(); TempData["OrderId"] = order.Id; SendOrderMail(order); CheckAndUpgradeMember(order.Member); //Call Pay gateway return(RedirectToAction("InitiateCreditTransaction", new { transAmount = order.TotalPrice, orderId = order.Id })); } return(View("CheckOut")); }
async Task ExecuteLoadItemsCommand() // Will load the items in this section { if (IsBusy) { return; } IsBusy = true; try { CartItems.Clear(); ListCartItems = App.userCart.Items; var cartitems = ListCartItems; // Add the list of menuItems from the userCart foreach (var menuitem in cartitems) { CartItems.Add(menuitem); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public ActionResult Finish(FormCollection form) { if (CartItems.Count <= 0) { return(RedirectToAction("Index", "Cart")); } var order = new OrderHeader(); order.OrderDate = DateTime.Now; if (TryUpdateModel(order)) { order.OrderDetails = GetOrderDetails(); order.TotalPrice = CartItems.Sum(item => item.Price); order.Member = db.Members.First(m => m.Email == User.Identity.Name); order.OrderStatus = db.OrderStatuses.First(os => os.Id == 1); StockSellOut(order); db.Orders.Add(order); db.SaveChanges(); CartItems.Clear(); TempData["OrderId"] = order.Id; SendFinishedOrderMail(order); return(RedirectToAction("Finish")); } return(View("CheckOut")); }
private void OnClearCart() { CartItems.Clear(); _chainOneTotal = 0; _chainTwoTotal = 0; _chainThreeTotal = 0; OnPropertyChanged(nameof(ChainOneTotal)); OnPropertyChanged(nameof(ChainTwoTotal)); OnPropertyChanged(nameof(ChainThreeTotal)); ClearLowAndHighCollections(); }
private void OnClearExecute(object obj) { _chainOneTotal = 0; _chainTwoTotal = 0; _chainThreeTotal = 0; OnPropertyChanged(nameof(ChainOneTotal)); OnPropertyChanged(nameof(ChainTwoTotal)); OnPropertyChanged(nameof(ChainThreeTotal)); _eventAggregator.GetEvent <ClearCartEvent>().Publish(CartItems.ToList()); CartItems.Clear(); ClearLowAndHighCollections(); }
private void LoadCart() { CartItems.Clear(); GrandTotal = 0; var kids = UserProfileService.Instance.CurrentUserProfile.Kids; if (kids == null || kids.Count == 0) { kids = new List <string>() { "My Child" }; } foreach (var product in Products) { var productOrders = _orderHistoryService.Orders.Where(o => o.ProductType == product.Name && o.Status == (int)OrderStatus.Pending); if (productOrders.Any()) { foreach (var kid in kids) { var ordersByKid = productOrders.Where(o => o.Child == kid); if (ordersByKid.Any()) { decimal total = 0; int count = 0; foreach (var o in ordersByKid) { count++; total += product.Price; } var cartItem = new CartItem { Id = Guid.NewGuid().ToString(), Glyph = product.Glyph, Price = product.Price.ToString("C"), ProductType = product.Name, Child = kid, Quantity = count.ToString(), Total = total.ToString("C") }; CartItems.Add(cartItem); GrandTotal += total; } } } } }
private void LoadItems() { var cn = DependencyService.Get <ISQLite>().GetConnection(); var items = cn.Table <CartItem>().ToList(); CartItems.Clear(); foreach (var item in items) { CartItems.Add(new UserCartItem() { CartItemId = item.CartId, ProductId = item.ProductId, ProductName = item.ProductName, Price = item.Price, Quantity = item.Quantity, Cost = item.Price * item.Quantity }); TotalCost += (item.Price * item.Quantity); } }
public void Clear() { CartItems.Clear(); }
public void Clear() { doInTransaction(((realm, ignored) => (realm as Realm).RemoveAll()), realm, null); CartItems.Clear(); TotalPrice = 0; }
public static void ClearCart() { CartItems.Clear(); PromoCode = string.Empty; Promo = null; }