Ejemplo n.º 1
0
        public void AddUser()
        {
            AddUser dlg = new AddUser();

            var           employeesWithNoUser = _handler.GetEmployeesWithNoUser();
            List <string> employeesFullName   = new List <string>();

            foreach (var emp in employeesWithNoUser)
            {
                employeesFullName.Add(emp.GetEmployeeInfo().FirstName + " " + emp.GetEmployeeInfo().LastName);
            }
            dlg.SetUserBox(employeesFullName);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string[] fullName     = dlg.User.Split(' ');
                var      employee     = _handler.FindEmployeeByName(fullName[0], fullName[1]);
                var      employeeInfo = employee.GetEmployeeInfo();

                var user = new User
                {
                    UserId   = employeeInfo.Id,
                    Username = dlg.Username,
                    Password = dlg.Password
                };

                _userAuthentication.AddUser(user);
            }
        }