private void UpdateMenu() { _collectionMenu.Clear(); try { _menuBusiness.GetAllMenus().ForEach(m => _collectionMenu.Add(m)); } catch (Exception ex) { DialogService.ShowErrorWindow(ex.Message); } }
public UserControlCafeteriaViewModel() { _platBusiness = new PlatBusiness(); _menuBusiness = new MenuBusiness(); _produitBusiness = new ProduitBusiness(); _openDeletingMenuWindow = new RelayCommand(() => DialogService.ShowYesNoWindow("Etes-vous sûr de vouloir supprimer ce menu ?", new Action(DeleteMenu)), o => true); _openDeletingPlatWindow = new RelayCommand(() => DialogService.ShowYesNoWindow("Etes-vous sûr de vouloir supprimer ce plat ?", new Action(DeletePlat)), o => true); _openDeletingProduitWindow = new RelayCommand(() => DialogService.ShowYesNoWindow("Etes-vous sûr de vouloir supprimer ce produit ?", new Action(DeleteProduit)), o => true); _openAddingPlatWindow = new RelayCommand(() => DialogGerant.ShowAjoutMenuView(), o => true); _openAddingMenuWindow = new RelayCommand(() => DialogGerant.ShowAjoutPlatView(), o => true); _openAddingProduitWindow = new RelayCommand(() => DialogGerant.ShowAjoutProduitView(), o => true); _openModifyingMenuWindow = new RelayCommand(() => DialogGerant.ShowModifMenuView(), o => true); _openModifyingPlatWindow = new RelayCommand(() => DialogGerant.ShowModifPlatView(), o => true); _openModifyingProduitWindow = new RelayCommand(() => DialogGerant.ShowModifProduitView(), o => true); _duplicateMenuCommand = new RelayCommand(() => DialogService.ShowYesNoWindow("Etes-vous sûr de vouloir dupliquer ce menu ?", new Action(DuplicateMenu)), o => true); _addToMenusDuJour = new RelayCommand(() => AddToMenuDuJour(), o => true); Messenger.Default.Register <string>(this, (msg) => HandleMessage(msg)); try { foreach (Plat plat in _platBusiness.GetAllPlat()) { _collectionPlat.Add(plat); } foreach (Menu menu in _menuBusiness.GetAllMenus()) { _collectionMenu.Add(menu); } foreach (Produit produit in _produitBusiness.GetAllProduits()) { _collectionProduit.Add(produit); } foreach (Menu menu in _menuBusiness.GetMenusDuJour()) { _collectionMenuDuJour.Add(menu); } } catch (Exception ex) { DialogService.ShowErrorWindow(ex.Message); } }