private void UpdatePlat() { _collectionPlat.Clear(); try { _platBusiness.GetAllPlat().ForEach(p => _collectionPlat.Add(p)); } 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); } }
public ModifMenuViewModel() { Messenger.Default.Register <Menu>(this, (menu) => HandleMessage(menu)); Messenger.Default.Send <string>("RequestSelectedMenu"); Nom = ModifyedMenu.Nom; DateElaboration = ModifyedMenu.DateElaboration; Observation = ModifyedMenu.Observation; _menuBusiness = new MenuBusiness(); _utilisateurBusiness = new UtilisateurBusiness(); _platBusiness = new PlatBusiness(); _addPlat = new RelayCommand(() => AddNewPlatToMenu(), o => true); _removePlat = new RelayCommand(() => DeletePlatFromMenu(), o => true); _apply = new RelayCommand(() => { Modify(); Close(); }, o => true); try { foreach (Plat p in ModifyedMenu.ListPLats) { _collectionSelectedPat.Add(p); } List <Plat> list = new List <Plat>(); list.AddRange(_platBusiness.GetAllPlat().Except(ModifyedMenu.ListPLats)); foreach (Plat p in list) { _collectionAvalaiblePat.Add(p); } _availableCategories = _menuBusiness.GetAllCategories(); _avalaibleGerant = _utilisateurBusiness.GetUtilisateursByFonction("Gérant"); } catch (Exception ex) { DialogService.ShowErrorWindow(ex.Message); } }