示例#1
0
        public void RemoveEmployee()
        {
            database.Employees.Clear();
            employeeLogic.AddEmployee(testEmployee);
            if (!database.GetAllEmployees().Contains(testEmployee))
            {
                Assert.Fail();
            }

            employeeLogic.RemoveEmployee(testEmployee);

            Assert.IsFalse(database.GetAllEmployees().Contains(testEmployee));
        }
示例#2
0
        /// <summary>
        /// Button click event that when triggered removes the employee.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnRemoveEmployee_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show($"Weet je zeker dat je {LvEmployees.SelectedItems[0].Text} wilt verwijderen?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                foreach (ListViewItem item in LvEmployees.SelectedItems)
                {
                    Employee E = new Employee()
                    {
                        name        = item.Text,
                        age         = int.Parse(item.SubItems[1].Text),
                        gender      = (Employee.Gender)Enum.Parse(typeof(Employee.Gender), item.SubItems[2].Text),
                        address     = item.SubItems[3].Text,
                        phoneNumber = item.SubItems[4].Text
                    };

                    employeeLogic.RemoveEmployee(E);
                    UpdateEmployeeList();
                }
            }
        }
 public IActionResult Remove(int id)
 {
     EmployeeLogic.RemoveEmployee(id);
     return(RedirectToAction("EmployeeHome"));
 }