Пример #1
0
        private void btn_update_Click(object sender, EventArgs e)
        {
            String malefemale = "";

            if (rb_female.Checked)
            {
                malefemale = "Female";
            }
            else
            {
                malefemale = "Male";
            }
            int role = 0;

            if (cbb_employee_roles.SelectedIndex == 0)
            {
                role = 2;
            }
            else
            {
                role = 3;
            }
            if (string.IsNullOrWhiteSpace(txt_employee_password.Text))
            {
                txt_employee_password.Text = null;
            }
            Employee employee = new Employee(selectedEmployee.EmployeeId, txt_employee_firstname.Text, txt_employee_lastname.Text, txt_employee_email.Text, txt_employee_phoneno.Text, (int)num_employee_exp.Value, malefemale, txt_employee_biography.Text, role);

            employee.Password = txt_employee_password.Text;
            employeesController.EditEmployee(employee);
            ReloadForm();
        }
Пример #2
0
        public void CheckIfEditEmployeeWorks()
        {
            // Arrange
            var employeesController = new EmployeesController()

            {
                Request = new HttpRequestMessage
                {
                    RequestUri = new Uri("http://localhost:44382/api/employees")
                },
                Configuration = new HttpConfiguration()
            };

            try
            {
                // Act
                var      result = employeesController.GetEmployee(1);
                Employee employee;
                result.TryGetContentValue <Employee>(out employee);
                string noneupdatedtitle = employee.FirstName;
                employee.FirstName = "Test";
                var      response  = employeesController.EditEmployee(employee);
                var      newresult = employeesController.GetEmployee(1);
                Employee actual;

                newresult.TryGetContentValue <Employee>(out actual);

                // Assert
                Assert.IsTrue(response.IsSuccessStatusCode);
                Assert.AreNotEqual(actual.FirstName, noneupdatedtitle);
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }