public IActionResult Add(AddEmployeeModel employee) { EmployeeBusiness employeeBusiness = new EmployeeBusiness(); var result = employeeBusiness.AddEmployee(employee); return(Ok(result)); }
private void btnThem_Click(object sender, EventArgs e) { Employee employee = new Employee(); employee.EmployeeName = txtTenNV.Text; bool gt = false; if (rbNam.Checked) { gt = true; } else { gt = false; } employee.Gender = gt; employee.Adress = txtDiaChi.Text; employee.Age = int.Parse(txtTuoi.Text); employee.Email = txtEmail.Text; employee.Phone = txtSDT.Text; if (EB.AddEmployee(employee)) { MessageBox.Show("Thêm thành công"); } else { MessageBox.Show("Thêm thất bại"); } DisplayData(); clearText(); }
public void AddEmployee_EmployeeIsNotNull_EmployeeFirstNameShouldBeJohn() { _unitOfWork.Setup(uow => uow.Employees.Add(_employee)); _business = new EmployeeBusiness(_unitOfWork.Object); var result = _business.AddEmployee(_dto); Assert.That(result.FirstName, Is.EqualTo("John")); }
public void AddEmployee_EmployeeIsNotNull_AddEmployeeToDatabase() { _unitOfWork.Setup(uow => uow.Employees.Add(_employee)); _business = new EmployeeBusiness(_unitOfWork.Object); _business.AddEmployee(_dto); _unitOfWork.Verify(uow => uow.Employees.Add(It.Is <Employee>(e => e.FirstName == "John")), Times.Once); }
public async Task AddEmployee_ShouldAddEmployee() { Mock <IEmployeeData> mock = new Mock <IEmployeeData>(); //Arrange Employees employee = new Employees() { EmployeeId = 1, EmployeeName = "Prathamesh", Gender = "Male", BirthDate = System.DateTime.Now }; mock.Setup(x => x.AddEmployee(employee)).ReturnsAsync("added"); EmployeeBusiness employeeBusiness = new EmployeeBusiness(mock.Object); //Act string actual = await employeeBusiness.AddEmployee(employee); //Assert Assert.AreEqual(actual, "added"); }
private void btnAddData_Click(object sender, EventArgs e) { Employee.MaNhanVien = int.Parse(txtEmployeeID.Text); Employee.TenNhanVien = txtEmployeeName.Text.Trim(); Employee.Tuoi = int.Parse(txtAge.Text); Employee.SoDT = txtPhoneNumber.Text; Employee.GioiTinh = cbGender.Text; Employee.MaLoaiNV = int.Parse(cbEmployeeTypeID.SelectedValue.ToString()); if (isAdd == true) { int result = EmployeeBusiness.AddEmployee(Employee); if (result == 1) { MessageBox.Show("Added successfully!", "Add a new Employee"); pnlPostData.Hide(); } else { MessageBox.Show("Failed to add a new Employee!", "Add a new Employee"); } } else { int result = EmployeeBusiness.EditEmployee(Employee); if (result == 1) { MessageBox.Show("Edited successfully!", "Edit a Employee"); pnlPostData.Hide(); } else { MessageBox.Show("Failed to edit a Employee!", "Edit a Employee"); } } loadData(); }
public void AddEmployee_EmployeeIsNull_ThrowArgumentNullException() { _business = new EmployeeBusiness(_unitOfWork.Object); Assert.That(() => _business.AddEmployee(null), Throws.ArgumentNullException); }