public void WhenAddCalled_CallsRepository_AndReturnsCorrectResult() { // Arrange Employee employee = _fixture.Create <Employee>(); _employeesRepository.Setup(r => r.Add(employee)).Returns(true); // Act (bool isSuccess, string errorMessage)result = _employeesService.AddEmployee(employee); // Assert _employeesRepository.Verify(r => r.Add(employee)); Assert.That(result.isSuccess); }
public IActionResult Post([FromBody] EmployeeModel newEmployee) { try { employeesService.AddEmployee(newEmployee); return(Ok()); }catch (Exception e) { return(ThrowInternalServerError(e)); } }
public string Execute(params string[] args) { var firstName = args[0]; var lastName = args[1]; var salary = decimal.Parse(args[2]); var employeeDto = new EmployeeDto(firstName, lastName, salary); employeeService.AddEmployee(employeeDto); return($"Employee {firstName} {lastName} successfully added."); }
public IActionResult Post(Employee employee) { try { _employeeService.AddEmployee(employee); return(new StatusCodeResult(201)); } catch { return(BadRequest()); } }
private void BtnClick_Add(object sender, RoutedEventArgs e) { Employee newEmployee = new Employee(); if (ValidateInputs()) { newEmployee.Id = int.Parse(uiTextboxId.Text); newEmployee.Lastname = uiTextboxLastname.Text; newEmployee.Firstname = uiTextboxFirstname.Text; if (_employeesService.AddEmployee(newEmployee) == false) { MessageBox.Show("Konnte den Mitarbeiter nicht hinzufügen. Personalnummer ist bereits in Verwendung."); } CollectionViewSource.GetDefaultView(uiMitarbeiterGrid.ItemsSource).Refresh(); } }
public IActionResult AddEmployee([FromBody] EmployeeVM employee) { _employeesService.AddEmployee(employee); return(Ok()); }