public BonListViewModel(IList <IReceipt> bons, ShopAdminViewModel shopAdmin, DBConnector dbConnection) { this._DBConnection = dbConnection; this._bons = bons; this._shopAdmin = shopAdmin; ReloadViewmodel(); CreateBonCommand = new ActionCommand(CreateBon, null); BalanceBonsCommand = new ActionCommand(BalanceBons, CanBalanceBons); MarkAllBonsCommand = new ActionCommand(MarkAllBons, CanMarkAllBons); }
public BonAdminViewModel(Project project, ShopAdminViewModel shopAdmin, DBConnector dbConnection) { _dbConnection = dbConnection; _project = project; // offene Bons laden IList <IReceipt> openBons = _project.Bons.Where(x => !x.Settled).ToList(); _openBons = new BonListViewModel(openBons, shopAdmin, dbConnection); _openBons.PropertyChanged -= BonsWereBalanced; _openBons.PropertyChanged += BonsWereBalanced; // geschlossene Bons laden IList <IReceipt> settledBons = _project.Bons.Where(x => x.Settled).ToList(); _settledBons = new BonListViewModel(settledBons, shopAdmin, dbConnection); }
/// <summary> /// Wird bei Start verwendet. Ruft einfach nur den zweiten Konstruktor auf /// </summary> public MainViewModel() { // Elemente aus dB laden _DBConnection = new DBConnector(); LoadProject(); // Admin für Kategorien laden und mit Kategorien befüllen _categoryAdmin = new CategoryAdminViewModel(_project.Categories, _DBConnection); _categoryAdmin.PropertyChanged -= ShopsChanged; _categoryAdmin.PropertyChanged += ShopsChanged; // Admin für Shop befüllen und mit Geschäften befüllen _shopAdmin = new ShopAdminViewModel(_project.Shops, _DBConnection); _shopAdmin.PropertyChanged -= ShopsChanged; _shopAdmin.PropertyChanged += ShopsChanged; // BonAdmin laden, enthält ShopAdmin und Projekt _bonAdmin = new BonAdminViewModel(_project, _shopAdmin, _DBConnection); }