示例#1
0
 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}");
            }
        }
示例#3
0
        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();
        }
示例#5
0
        public void RemoveItem(Widget widget)
        {
            var cartItem = CartItems.Where(x => x.WidgetId == widget.WidgetId).FirstOrDefault();

            if (cartItem != null)
            {
                CartItems.Remove(widget);
            }
        }
示例#6
0
        public void RemoveCartItemWithProduct(int productId)
        {
            var removedItem = CartItems.FirstOrDefault(x => x.ProductId == productId);

            if (removedItem != null)
            {
                CartItems.Remove(removedItem);
            }
        }
示例#7
0
        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();
 }
示例#9
0
 public bool Remove(CartItem item)
 {
     if (CartItems.Remove(item))
     {
         TotalSum -= item.Item.Price * item.Quantity;
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#10
0
 public void SubtractProduct(CartItem cartItem)
 {
     if (cartItem.Quantity <= 1)
     {
         CartItems.Remove(cartItem);
     }
     else
     {
         cartItem.TotalPrice -= cartItem.Product.Price;
         cartItem.Quantity--;
     }
     RefreshTotalAmount();
 }
示例#11
0
        /// <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);
        }
示例#12
0
        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();
        }
示例#13
0
        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());
            }
        }
示例#14
0
        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());
            }
        }
示例#15
0
 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();
     }
 }
示例#16
0
        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}");
            }
        }
示例#18
0
 public void RemoveCartItemByProductId(int id)
 {
     CartItems.Remove(GetCartItemByProductId(id));
 }
示例#19
0
 public void Remove(CartItem cartItem)
 {
     CartItems.Remove(cartItem);
 }
示例#20
0
 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.
 }
示例#21
0
 /// <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--;
 }
示例#22
0
文件: Cart.cs 项目: PDanowski/CuStore
        public void RemoveProduct(int productId)
        {
            var item = CartItems.FirstOrDefault(i => i.ProductId.Equals(productId));

            CartItems.Remove(item);
        }
示例#23
0
 private void OnRemove(object item)
 {
     CartItems.Remove(item as CartItem);
 }