public void RemoveFromCart() { SelectedItemToRemove.QuantityInCart -= ItemQuantity; ProductDisplayModel restockItem = Products.FirstOrDefault(x => x.Equals(SelectedItemToRemove.Product)); restockItem.QuantityInStock += ItemQuantity; if (SelectedItemToRemove.QuantityInCart == 0) { Cart.Remove(SelectedItemToRemove); } ItemQuantity = 1; NotifyOfPropertyChange(() => SubTotal); NotifyOfPropertyChange(() => Tax); NotifyOfPropertyChange(() => Total); NotifyOfPropertyChange(() => CanCheckOut); }
public void RemoveFromCart() { CartItemDisplayModel existingItem = Cart.FirstOrDefault(x => x.Product == SelectedProductToRemove.Product); existingItem.QuantityInCart -= ItemQuantity; //HACK - There should be a better way of refreshing the cart display Cart.Remove(existingItem); if (existingItem.QuantityInCart > 0) { Cart.Add(existingItem); } ProductDisplayModel ProductInStock = Products.FirstOrDefault(x => x.Id == existingItem.Product.Id); ProductInStock.QuantityInStock += ItemQuantity; ItemQuantity = 1; NotifyOfPropertyChange(() => SubTotal); NotifyOfPropertyChange(() => Tax); NotifyOfPropertyChange(() => Total); NotifyOfPropertyChange(() => CanCheckOut); }