예제 #1
0
        //author: Michael Kath (n9293833)
        public FindViewModel(IDialogService dialog, IUserDatabase locationsDatabase, string currentUser)
        {
            this.dialog        = dialog;
            this.currentUser   = currentUser;
            User               = new ObservableCollection <Employees>();
            this.UsersDatabase = locationsDatabase;

            ListOutStandingReq = new ObservableCollection <AddRequest>();
            RetrieveRequests();
            RetrieveEmployees();



            SelectLocationCommand = new MvxCommand <Employees>(selectedLocation =>
            {
                SelectUserFromSearch(selectedLocation, dialog);
                SearchTerm = string.Empty;
                RaisePropertyChanged(() => SearchTerm);
            });

            // if a request item on the list is pressed (USED FOR TESTING ATM)
            SelectReqCommand = new  MvxCommand <AddRequest> (req =>
            {
                UsersDatabase.DeleteRequest(req.UserNameReq, currentUser);
                RetrieveRequests();
            });
        }
예제 #2
0
        //author: Michael Kath (n9293833)
        //Adds User to list if he doesnt exist
        public async void SelectUserFromSearch(Employees selectedUser, IDialogService dialog)
        {
            if (selectedUser.UserName != "Searching..." && selectedUser.UserName != "No matches found")
            {
            }
            {
                if (!await UsersDatabase.CheckIfExists(selectedUser, currentUser))
                {
                    InsertReqDB(selectedUser);
                }
                else
                {
                    if (await dialog.Show("You have already added a request", "Request Exists", "Send Another", "Go Back"))
                    {
                        await UsersDatabase.DeleteRequest(selectedUser.UserName, currentUser);

                        InsertReqDB(selectedUser);
                        RetrieveRequests();
                    }
                }
            }
        }