Beispiel #1
0
        public AjoutMenuViewModel()
        {
            _menuBusiness        = new MenuBusiness();
            _utilisateurBusiness = new UtilisateurBusiness();

            DateElaboration = DateTime.Now;

            try
            {
                _availableCategories = _menuBusiness.GetAllCategories();
                _avalaibleGerant     = _utilisateurBusiness.GetUtilisateursByFonction("Gérant");
            }
            catch (Exception ex)
            {
                DialogService.ShowErrorWindow(ex.Message);
            }

            _createMenuCommand = new RelayCommand(() => { CreateNewMenu(); Messenger.Default.Send <string>("UpdateMenu"); Close(); }, o => true);
        }
        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);
            }
        }