Example #1
0
        public void GetUsers()
        {
            Controller ctrl = new Controller();
            List<PersonDTO> listOfUsers = ctrl.GetAllUsers();

            mitoden_dbgr13Entities db = new mitoden_dbgr13Entities();
            var dblist = db.Person1.Where(p => p.trueorfalse == false).ToList();

            Assert.AreEqual(listOfUsers.Count, dblist.Count);

            for (int i = 0; i < listOfUsers.Count; i++)
            {
                Assert.AreEqual(listOfUsers[i].UserName, dblist[i].PK_Username);
            }
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            mitoden_dbgr13Entities db = new mitoden_dbgr13Entities();
            try
            {
                this._controllerProxy.DeleteUser(userCombo.SelectedItem.ToString());
                MessageBox.Show("User deleted");
                FillUserCombo();

            }
            catch (Exception)
            {
                MessageBox.Show("Unexpected error. Try again.");
            }
        }
Example #3
0
        public void GetDevices()
        {
            Controller ctrl = new Controller();
            List<DeviceDTO> listOfDevices = ctrl.GetAllDeviceID();

            mitoden_dbgr13Entities db = new mitoden_dbgr13Entities();
            var dblist = db.Device.ToList();

            Assert.AreEqual(listOfDevices.Count, dblist.Count);

            for (int i = 0; i < listOfDevices.Count; i++)
            {
                Assert.AreEqual(listOfDevices[i].DeviceID, dblist[i].PK_DeviceID);
                Assert.AreNotEqual(listOfDevices[i].DeviceID, "lalala");
            }
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            mitoden_dbgr13Entities db = new mitoden_dbgr13Entities();
            List<Person1> mylist = new List<Person1>();

            try
            {
                mylist = db.Person1.ToList();
                for (int i = 0; i < mylist.Count; i++)
                {
                    if (UserNameTextBox.Text == mylist[i].PK_Username && PasswordBox.Password == mylist[i].Password)
                    {
                        if (mylist[i].trueorfalse == true)
                        {
                            AdminWindow adw = new AdminWindow();
                            adw.Show();

                        }

                        if (mylist[i].trueorfalse == false)
                        {
                            StatisticsWindow stw = new StatisticsWindow(UserNameTextBox.Text);
                            stw.Show();
                        }

                        this.Hide();
                        UserNameTextBox.Text = "";
                        PasswordBox.Password = "";
                        return;
                    }
                    else
                    {
                    }
                }
                MessageBox.Show("Invalid Username or Password. Please try again.");
            }
            catch (Exception)
            {
                MessageBox.Show("Error");
            }
        }