using examPrepare.Models; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace examPrepare.ViewModels { public class CartViewModel : INotifyPropertyChanged { private List _products = new List(); public List Products { get { return _products; } set { _products = value; OnPropertyChanged("Products"); } } public void notifyChange() { OnPropertyChanged("Products"); } public CartViewModel() { List rawProcuts = GlobalInfo.conn.Product.ToList(); foreach (Product product in rawProcuts) { if (GlobalInfo.cart.ContainsKey(product.ProductArticleNumber)) { ProductModel p = new ProductModel(product); p.count = GlobalInfo.cart[product.ProductArticleNumber]; _products.Add(p); } } } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } }