public void DoPromotion() { if (CartItems.Count > 0) { var subtotal = CartItems.Where(w => w.isProduct == true).Sum(s => s.Price * s.Quantity); var itemFreight = CartItems.FirstOrDefault(f => f.isProduct == false); if (itemFreight != null) { CartItems.Remove(itemFreight); } #region frieght if (subtotal < 200000) { var frieght = new CartItem(); frieght.isProduct = false; frieght.Price = 0; frieght.ProductName = "Phí vận chuyển"; frieght.ProductCode = "FRIEGHTCODE"; frieght.Quantity = 1; CartItems.Add(frieght); } else { var frieght = new CartItem(); frieght.isProduct = false; frieght.Price = 0; frieght.ProductName = "Phí vận chuyển"; frieght.ProductCode = "FREEFRIEGHT"; frieght.Quantity = 1; CartItems.Add(frieght); } #endregion } }
public async void DeleteItem(object Index) { try { OrdersItems = await client.GetAllOfflineSyncItemsAsync <OrderItems>(OrdersItemsTable); Item item = CartItems[(int)Index]; Order Order = Orders.FirstOrDefault(o => (o.UserID == SharedUser.ID && (o.SubmittedOffline == false || o.SubmittedOnline == false))); var orderi = OrdersItems.FirstOrDefault(oi => oi.ItemID == item.ID && oi.OrderID == Order.ID); OrdersItems.Remove(orderi); await client.DeleteOfflineSyncObjectAsync(orderi, OrdersItemsTable); if (CartItems.Contains(CartItems[(int)Index])) { CartItems.Remove(CartItems[(int)Index]); if (CartItems.Count == 0) { IsCartNotEmpty = false; } } await Application.Current.MainPage.Navigation.PopAsync(); await NavigationHelper.NavigateToPageAsync(new ShoppingCartPage()); } catch (Exception ex) { Console.WriteLine($"Message : {ex.Message} \n StackTrace : {ex.StackTrace}"); } }
public IList <CartItem> Remove(string productId, int quantity, out IList <CartItemDetail> shoppingCartItemDetailsRemoved) { IList <CartItem> itemRemoves = new List <CartItem>(); shoppingCartItemDetailsRemoved = new List <CartItemDetail>(); bool isRemove = false; for (int i = 0; i < quantity; i++) { var item = CartItems.FirstOrDefault(p => p.ProductId == productId); if (item != null) { CartItems.Remove(item); isRemove = true; itemRemoves.Add(item); } } if (isRemove) { var item = CartItems.FirstOrDefault(p => p.ProductId == productId); if (item == null) { if (CartItemDetails.ContainsKey(productId)) { shoppingCartItemDetailsRemoved.Add(CartItemDetails[productId]); CartItemDetails.Remove(productId); } } } RemoveItemEvent(itemRemoves, shoppingCartItemDetailsRemoved); return(itemRemoves); }
public async Task DeleteCartItem(int id) { var item = await CartItems.FirstAsync(i => i.Id == id); CartItems.Remove(item); await SaveChangesAsync(); }
public void RemoveItem(Widget widget) { var cartItem = CartItems.Where(x => x.WidgetId == widget.WidgetId).FirstOrDefault(); if (cartItem != null) { CartItems.Remove(widget); } }
public void RemoveCartItemWithProduct(int productId) { var removedItem = CartItems.FirstOrDefault(x => x.ProductId == productId); if (removedItem != null) { CartItems.Remove(removedItem); } }
public void RemoveCartItem(int cartItemId) { var removedItem = CartItems.FirstOrDefault(x => x.Id == cartItemId); if (removedItem != null) { CartItems.Remove(removedItem); } }
public CartViewModel() { realm = Realm.GetInstance(); RemoveItem = new RelayCommand <CartItem>((item) => { CartItems.Remove(item); doInTransaction(((o1, o2) => (o1 as Realm).Remove(o2 as CartItem)), realm, item); CalcTotalPrice(); }); LoadCart(); }
public bool Remove(CartItem item) { if (CartItems.Remove(item)) { TotalSum -= item.Item.Price * item.Quantity; return(true); } else { return(false); } }
public void SubtractProduct(CartItem cartItem) { if (cartItem.Quantity <= 1) { CartItems.Remove(cartItem); } else { cartItem.TotalPrice -= cartItem.Product.Price; cartItem.Quantity--; } RefreshTotalAmount(); }
/// <summary> /// Usunięcie elementu z koszyka na podstawie nr id /// </summary> /// <param name="id"></param> public bool DeleteFromCartById(int id) { ElectronicDeviceViewModel temp = CartItems.Find(x => x.ID == id); if (temp is null) { return(false); } TotalPrice -= temp.Price; NumberOfElements--; CartItems.Remove(temp); return(true); }
public void SubtractProduct(Product product) { var cartItem = CartItems.FirstOrDefault(x => x.Product == product); if (cartItem.Quantity <= 1) { CartItems.Remove(cartItem); } else { cartItem.TotalPrice -= cartItem.Product.Price; cartItem.Quantity--; } RefreshTotalAmount(); }
public ActionResult Delete(int id) { Thread.Sleep(1000); CartItem inCartItem = CartItems.FirstOrDefault(item => item.Id == id); if (inCartItem != null) { CartItems.Remove(inCartItem); return(new HttpStatusCodeResult(200, "資料已刪除")); } else { return(HttpNotFound()); } }
public ActionResult Delete(int id) { Thread.Sleep(1000); CartItem inCartItem = CartItems.FirstOrDefault(item => item.Id == id); if (inCartItem != null) { CartItems.Remove(inCartItem); return(RedirectToAction("Index")); } else { return(HttpNotFound()); } }
private void OnRemoveExecute(object obj) { _chainOneTotal -= _selectedItem.ChainOneTotalPrice; _chainTwoTotal -= _selectedItem.ChainTwoTotalPrice; _chainThreeTotal -= _selectedItem.ChainThreeTotalPrice; OnPropertyChanged(nameof(ChainOneTotal)); OnPropertyChanged(nameof(ChainTwoTotal)); OnPropertyChanged(nameof(ChainThreeTotal)); _eventAggregator.GetEvent <ProductRemovedFromCartEvent>().Publish(_selectedItem); CartItems.Remove(_selectedItem); if (CartItems.Count >= 6) { UpdateLowAndHighPrices(); } else { ClearLowAndHighCollections(); } }
public IActionResult OnPostMinus(int id) { CartItems = HttpContext.Session.GetObjectFromJson <List <ShoppingCart> >("CartItems").ToList(); var productiInCart = CartItems.SingleOrDefault(x => x.Product.Id == id); var cartItemMinus = cartBL.MinusCartItem(productiInCart); if (cartItemMinus == null) { CartItems.Remove(productiInCart); } else { CartItems .Where(x => x.Id == id) .Select(x => { x.Quantity = cartItemMinus.Quantity; return(x); }).ToList(); } HttpContext.Session.SetObjectAsJson("CartItems", CartItems); CartItems = HttpContext.Session.GetObjectFromJson <List <ShoppingCart> >("CartItems").ToList(); return(RedirectToPage("./ShoppingCart")); }
public async void DeleteItemFromSQLLite(object Index) { try { await _connection.DeleteAsync(SQLITEItems[(int)Index]); if (CartItems.Contains(CartItems[(int)Index])) { CartItems.Remove(CartItems[(int)Index]); if (CartItems.Count == 0) { IsCartNotEmpty = false; } } await Application.Current.MainPage.Navigation.PopAsync(); await NavigationHelper.NavigateToPageAsync(new ShoppingCartPage()); } catch (Exception ex) { Console.WriteLine($"Message : {ex.Message} \n StackTrace : {ex.StackTrace}"); } }
public void RemoveCartItemByProductId(int id) { CartItems.Remove(GetCartItemByProductId(id)); }
public void Remove(CartItem cartItem) { CartItems.Remove(cartItem); }
public void RemoveItemFromCart(IItem item) { CartItems.Remove(item); //Needs to write logic wherein once product removed, We need to reiterate over all the products and apply discount. }
/// <summary> /// Usunięcie elementu z koszyka na podstawie przekazanego obiektu /// </summary> /// <param name="item"></param> public void DeleteFromCart(ElectronicDeviceViewModel item) { CartItems.Remove(item); TotalPrice -= item.Price; NumberOfElements--; }
public void RemoveProduct(int productId) { var item = CartItems.FirstOrDefault(i => i.ProductId.Equals(productId)); CartItems.Remove(item); }
private void OnRemove(object item) { CartItems.Remove(item as CartItem); }