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 CatalogViewModel : INotifyPropertyChanged
  {
    private List<ProductModel> _products = new List<ProductModel>();
    public List<ProductModel> Products 
    { get { return _products; } 
      set {  _products = value; OnPropertyChanged("Products"); } }
    public CatalogViewModel() 
    {
      List<Product> rawProducts = GlobalInfo.conn.Product.ToList();
      foreach (Product product in rawProducts)
      {
        _products.Add(new ProductModel(product));
      }
    }
    public event PropertyChangedEventHandler PropertyChanged;
    protected void OnPropertyChanged(string propertyName)
    {
      PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
  }
}
