示例#1
0
        public void TestAddDriverViewModel()
        {
            var viewmodel = new AddDriverViewModel(employeeService);

            int previousEmployeeCounter = employeeService.All().Count;

            viewmodel.SelectedStatus = "Active";

            // Aanmaken van een unieke username
            viewmodel.CurrentDriver.Username = "******" + logService.All().Count;

            viewmodel.CurrentDriver.Name     = "Test";
            viewmodel.CurrentDriver.SurName  = "Gebruiker";
            viewmodel.CurrentDriver.Password = "******";

            try
            {
                viewmodel.AddDriver(null);
            }
            catch (NullReferenceException)
            {
                // Navigation error
            }

            int expectedEmployeeCounter = previousEmployeeCounter + 1;
            var addedEmployee           = employeeService.FindByUsername(viewmodel.CurrentDriver.Username);

            Assert.IsNotNull(viewmodel.CurrentDriver);
            Assert.AreEqual(viewmodel.CurrentDriver.Clearance, Role.ROLE_ADMIN);
            Assert.IsTrue(viewmodel.StatusList.Contains("Active"));
            Assert.IsTrue(expectedEmployeeCounter == employeeService.All().Count);
            Assert.AreEqual(viewmodel.CurrentDriver.Password, PasswordHandler.Md5Encrypt("test123", addedEmployee.Salt));
        }
示例#2
0
        private void Login(object obj)
        {
            Employee employee       = service.FindByUsername(CurrentEmployee.Username);
            string   hashedPassword = PasswordHandler.Md5Encrypt(CurrentEmployee.Password, employee.Salt);

            if (hashedPassword == employee.Password)
            {
                LoggedUser.Employee_id = employee.Employee_id;
                LoggedUser.Name        = employee.Name;
                LoggedUser.Salt        = employee.Salt;
                LoggedUser.Status      = employee.Status;
                LoggedUser.SurName     = employee.SurName;

                new NavService().NavigateTo("Main");
            }
        }
        public void AddDriver(object obj)
        {
            if (SelectedStatus == "Active")
            {
                CurrentDriver.Status = true;
            }
            else
            {
                CurrentDriver.Status = false;
            }

            CurrentDriver.Salt     = PasswordHandler.GenerateSalt();
            CurrentDriver.Password = PasswordHandler.Md5Encrypt(CurrentDriver.Password, CurrentDriver.Salt);

            service.Add(CurrentDriver);
            Messenger.Default.Send(CurrentDriver);
            new NavService().NavigateTo("Drivers");
        }