Ejemplo n.º 1
0
 public Dictionary<Type, ISwitchable> CreatePages(User user)
 {
     var pages = new Dictionary<Type, ISwitchable>();
     switch (user.UserRole)
     {
         case Role.Vet:
             pages.Add(typeof (View.Vet.ProtegesPage), new View.Vet.ProtegesPage(new ProtegesPageViewModel(user)));
             pages.Add(typeof (View.Vet.MedicalProceduresPage), new View.Vet.MedicalProceduresPage(new ViewModel.Vet.MedicalProceduresPageViewModel(user)));
             pages.Add(typeof (DiseasePage), new DiseasePage(new DiseasePageViewModel(user)));
             break;
         case Role.Manager:
             pages.Add(typeof (View.Manager.EmployeesPage), new View.Manager.EmployeesPage(new ViewModel.Manager.EmployeesPageViewModel(user)));
             pages.Add(typeof (View.Manager.AnimalsPage), new View.Manager.AnimalsPage(new ViewModel.Manager.AnimalsPageViewModel(user)));
             pages.Add(typeof (View.Manager.DiseasesPage), new View.Manager.DiseasesPage(new ViewModel.Manager.DiseasesPageViewModel(user)));
             pages.Add(typeof (View.Manager.MedicalProceduresPage), new View.Manager.MedicalProceduresPage(new ViewModel.Manager.MedicalProceduresPageViewModel(user)));
             break;
         case Role.RegularEmployee:
             pages.Add(typeof (CleaningPage), new CleaningPage(new CleaningPageViewModel(user)));
             pages.Add(typeof (FeedingPage), new FeedingPage(new FeedingPageViewModel(user)));
             pages.Add(typeof (View.RegularEmployee.ProtegesPage), new View.RegularEmployee.ProtegesPage(new RegularEmployee.ProtegesPageViewModel(user)));
             break;
         case Role.Admin:
             pages.Add(typeof (View.Admin.AnimalsPage), new View.Admin.AnimalsPage(new ViewModel.Admin.AnimalsPageViewModel(user)));
             pages.Add(typeof (CagesAndAreasPage), new CagesAndAreasPage(new CagesAndAreasPageViewModel(user)));
             pages.Add(typeof (View.Admin.EmployeesPage), new View.Admin.EmployeesPage(new ViewModel.Admin.EmployeesPageViewModel(user)));
             pages.Add(typeof (SpeciesPage), new SpeciesPage(new SpeciesPageViewModel(user)));
             pages.Add(typeof (View.Admin.DiseasesPage), new View.Admin.DiseasesPage(new ViewModel.Admin.DiseasesPageViewModel(user)));
             pages.Add(typeof (View.Admin.MedicalProceduresPage), new View.Admin.MedicalProceduresPage(new ViewModel.Admin.MedicalProceduresPageViewModel(user)));
             pages.Add(typeof (View.Admin.CleaningsAndFeedingsPage), new View.Admin.CleaningsAndFeedingsPage(new ViewModel.Admin.CleaningsAndFeedingsPageViewModel(user)));
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     return pages;
 }
Ejemplo n.º 2
0
 public MainWindow(Type page, User user, MainWindowViewModel viewModel)
 {
     InitializeComponent();
     Switcher.PageSwitcher = this;
     DataContext = viewModel;
     pages = viewModel.CreatePages(user);
     Switcher.Switch(page);
     Closing += viewModel.OnWindowClosing;
 }
Ejemplo n.º 3
0
        public ProtegesPageViewModel(User user)
            : base(user, new Dialoger(), new SQLSelect(), new SQLInsert(),new SQLUpdate(), new SQLDelete())
        {
            Genders = new List<Gender> { Gender.Male, Gender.Female, Gender.Gonomochronism, Gender.Intersex, Gender.NotSpecified };
            OnPropertyChanged("Genders");

            OpenEditAnimalWindowCommand = new RelayCommand(obj => OpenEditAnimalWindow());
            EditAnimalCommand = new RelayCommand(obj => EditAnimal());
        }
Ejemplo n.º 4
0
 public FeedingPageViewModel(User user)
     : base(user, new Dialoger(), new SQLSelect(), new SQLInsert(), new SQLUpdate(), new SQLDelete())
 {
     LoadData();
     AddFeedingCommand = new RelayCommand(obj => AddFeeding());
     RemoveFeedingCommand = new RelayCommand(obj => RemoveFeeding());
     OpenEditFeedingWindowCommand = new RelayCommand(obj => OpenEditFeedingWindow());
     EditFeedingCommand = new RelayCommand(obj => EditFeeding());
 }
Ejemplo n.º 5
0
        public DiseasePageViewModel(User user)
            : base(user, new Dialoger(), new SQLSelect(), new SQLInsert(), new SQLUpdate(), new SQLDelete())
        {
            LoadData();

            AddDiseaseCommand = new RelayCommand(obj => AddDisease());
            EditDiseaseCommand = new RelayCommand(obj => EditDisease());
            OpenEditDiseaseWindowCommand = new RelayCommand(obj => OpenEditDiseaseWindow());
            RemoveDiseaseCommand = new RelayCommand(obj => RemoveDisease());
        }
        public MedicalProceduresPageViewModel(User user)
            : base(user, new Dialoger(), new SQLSelect(), new SQLInsert(), new SQLUpdate(), new SQLDelete())
        {
            LoadData();

            AddMedicalProcedureCommand = new RelayCommand(obj => AddMedicalProcedure());
            EditMedicalProcedureCommand = new RelayCommand(obj => EditMedicalProcedure());
            RemoveMedicalProcedureCommand = new RelayCommand(obj => RemoveMedicalProcedure());
            OpenEditMedicalProcedureWindowCommand = new RelayCommand(obj => OpenEditMedicalProcedureWindow());
            OpenAddMedicineWindowCommand = new RelayCommand(obj => OpenAddMedicineWindow());
            AddMedicineCommand = new RelayCommand(obj => AddMedicine());
        }
Ejemplo n.º 7
0
        public EmployeesPageViewModel(User user)
            : base(new Dialoger(), user, new SQLSelect(), new SQLInsert(), new SQLUpdate())
        {
            LoadData();

            Genders = new List<Gender> {Gender.Male, Gender.Female};
            OnPropertyChanged("Genders");
            Roles = new List<Role> {Role.Manager, Role.Vet, Role.RegularEmployee};
            OnPropertyChanged("Roles");

            AddEmployeeCommand = new RelayCommand(obj => AddEmployee());
            OpenEditEmployeeWindowCommand = new RelayCommand(obj => OpenEditEmployeeWindow());
            EditEmployeeCommand = new RelayCommand(obj => EditEmployee());
        }
Ejemplo n.º 8
0
        public ManagerBaseViewModel(IDialoger dialoger, User user,
            ISQLSelect sqlSelect, ISQLInsert sqlInsert, ISQLUpdate sqlUpdate)
        {
            this.dialoger = dialoger;
            this.user = user;
            this.sqlSelect = sqlSelect;
            this.sqlInsert = sqlInsert;
            this.sqlUpdate = sqlUpdate;
            employee = sqlSelect.GetEmployee(this.user);

            EmployeesCommand = new RelayCommand(obj => GoToEmployeesPage());
            AnimalsCommand = new RelayCommand(obj => GoToAnimalsPage());
            DiseasesCommand = new RelayCommand(obj => GoToDiseasesPage());
            MedicalProceduresCommand = new RelayCommand(obj => GoToMedicalProceduresPage());
        }
Ejemplo n.º 9
0
        protected VetBaseViewModel(User user, IDialoger dialoger,
            ISQLSelect sqlSelect, ISQLInsert sqlInsert, ISQLUpdate sqlUpdate, ISQLDelete sqlDelete)
        {
            User = user;
            this.sqlSelect = sqlSelect;
            this.sqlInsert = sqlInsert;
            this.sqlUpdate = sqlUpdate;
            this.sqlDelete = sqlDelete;
            employee = sqlSelect.GetEmployee(User);
            this.dialoger = dialoger;

            LoadData();

            DiseasesCommand = new RelayCommand(obj => GoToDiseasePage());
            MedicalProceduresCommand = new RelayCommand(obj => GoToMedicalProceduresPage());
            ProtegesCommand = new RelayCommand(obj => GoToProtegesPage());
        }
Ejemplo n.º 10
0
        protected AdminBaseViewModel(User user, ISQLCredentials sqlCredentials, IDialoger dialoger, 
            ISQLSelect sqlSelect, ISQLInsert sqlInsert, ISQLUpdate sqlUpdate)
        {
            this.sqlCredentials = sqlCredentials;
            this.dialoger = dialoger;
            this.user = user;
            this.sqlSelect = sqlSelect;
            this.sqlInsert = sqlInsert;
            this.sqlUpdate = sqlUpdate;

            EmployeesCommand = new RelayCommand(obj => GoToEmployeesPage());
            AnimalsCommand = new RelayCommand(obj => GoToAnimalsPage());
            SpeciesCommand = new RelayCommand(obj => GoToSpeciesPage());
            CagesAndAreasCommand = new RelayCommand(obj => GoToCagesAndAreasPage());
            MedicalProceduresCommand = new RelayCommand(obj => GoToMedicineProceduresPage());
            DiseasesCommand = new RelayCommand(obj => GoToDiseasesPage());
            CleaningsAndFeedingsCommand = new RelayCommand(obj => GoToCleaningsAndFeedingsPage());
        }
        protected RegularEmployeeBaseViewModel(User user, IDialoger dialoger,
            ISQLSelect sqlSelect, ISQLInsert sqlInsert, ISQLUpdate sqlUpdate, ISQLDelete sqlDelete)
        {
            this.dialoger = dialoger;
            this.sqlSelect = sqlSelect;
            this.sqlInsert = sqlInsert;
            this.sqlUpdate = sqlUpdate;
            this.sqlDelete = sqlDelete;

            User = user;
            employee = sqlSelect.GetEmployee(User);

            LoadData();

            FeedingCommand = new RelayCommand(obj => GoToFeedingPage());
            CleaningCommand = new RelayCommand(obj => GoToCleaningPage());
            ProtegesCommand = new RelayCommand(obj => GoToProtegesPage());
        }
Ejemplo n.º 12
0
        private CagesAndAreasPageViewModel(User user, ISQLDelete sqlDelete)
            : base(user, new SQLCredentials(), new Dialoger(), new SQLSelect(), new SQLInsert(), new SQLUpdate())
        {
            this.sqlDelete = sqlDelete;

            LoadData();

            AddCageCommand = new RelayCommand(obj => AddNewCage());
            AddAreaCommand = new RelayCommand(obj => AddNewArea());

            OpenEditAreaWindowCommand = new RelayCommand(obj => OpenEditAreaWindow());
            OpenEditCageWindowCommand = new RelayCommand(obj => OpenEditCageWindow());

            EditCageCommand = new RelayCommand(obj => EditCage());
            EditAreaCommand = new RelayCommand(obj => EditArea());
            RemoveAreaCommand = new RelayCommand(obj => RemoveArea());
            RemoveCageCommand = new RelayCommand(obj => RemoveCage());
        }
Ejemplo n.º 13
0
        public AnimalsPageViewModel(User user)
            : base(user, new SQLCredentials(), new Dialoger(), new SQLSelect(), new SQLInsert(), new SQLUpdate())
        {
            LoadData();

            Genders = new List<Gender> { Gender.Male, Gender.Female, Gender.Gonomochronism, Gender.Intersex, Gender.NotSpecified };
            OnPropertyChanged("Genders");
            Areas = sqlSelect.GetListOfAreas();
            OnPropertyChanged("Areas");
            Species = sqlSelect.GetListOfAllSpecies();
            OnPropertyChanged("Species");
            Guards = sqlSelect.GetListOfAllGuards();
            OnPropertyChanged("Guards");
            Vets = sqlSelect.GetListOfAllVets();
            OnPropertyChanged("Vets");

            AddAnimalCommand = new RelayCommand(obj => AddNewAnimal());
            EditAnimalCommand = new RelayCommand(obj => EditAnimal());
            OpenEditAnimalWindowCommand = new RelayCommand(obj => OpenEditAnimalWindow());
        }
 public MedicalProceduresPageViewModel(User user)
     : base(new Dialoger(), user, new SQLSelect(), new SQLInsert(), new SQLUpdate())
 {
     LoadData();
 }
Ejemplo n.º 15
0
 public void LogIn(Type page, User user)
 {
     var pageSwitcher = new MainWindow(page, user, new MainWindowViewModel());
     pageSwitcher.Show();
     Close();
 }
Ejemplo n.º 16
0
 public ProtegesPageViewModel(User user)
     : base(user, new Dialoger(), new SQLSelect(), new SQLInsert(), new SQLUpdate(), new SQLDelete())
 {
     LoadData();
 }
Ejemplo n.º 17
0
 public DiseasesPageViewModel(User user)
     : base(new Dialoger(), user, new SQLSelect(), new SQLInsert(), new SQLUpdate())
 {
     LoadData();
 }
Ejemplo n.º 18
0
 public CagesAndAreasPageViewModel(User user)
     : this(user, new SQLDelete())
 {
 }
Ejemplo n.º 19
0
 public SpeciesPageViewModel(User user)
     : base(user, new SQLCredentials(), new Dialoger(), new SQLSelect(), new SQLInsert(), new SQLUpdate())
 {
     LoadData();
 }
 public CleaningsAndFeedingsPageViewModel(User user)
     : base(user, new SQLCredentials(), new Dialoger(), new SQLSelect(), new SQLInsert(), new SQLUpdate())
 {
     LoadData();
 }