public UpdateEmployeeCommand(EmployeeRest employee) { Id = employee.Id; FirstName = employee.FirstName; MiddleName = employee.MiddleName; LastName = employee.LastName; }
public async Task <ActionResult> Put(EmployeeRest employee) { var command = new UpdateEmployeeCommand(employee); await _mediator.Send(command); return(NoContent()); }
public async Task <ActionResult <int> > Post(EmployeeRest employee) { var command = new CreateEmployeeCommand(employee); var id = await _mediator.Send(command); return(Ok(id)); }
public async Task HandleValidEmployeeAddedToEmployeeRepo() { var handler = new CreateEmployeeCommandHandler(_mapper, _mockEmployeeRepository.Object); var employee = new EmployeeRest { FirstName = $"FirstName11", MiddleName = $"MiddleName11", LastName = $"LastName11" }; await handler.Handle(new CreateEmployeeCommand(employee), CancellationToken.None); var allCategories = await _mockEmployeeRepository.Object.GetAllAsync(); allCategories.Count.ShouldBe(10); }
public async Task HandleValidEmployeUpdatedToEmployeeRepo() { var handler = new UpdateEmployeeCommandHandler(_mapper, _mockEmployeeRepository.Object); var employee = new EmployeeRest { Id = 5, FirstName = "FirstName11", MiddleName = "MiddleName11", LastName = "LastName11" }; await handler.Handle(new UpdateEmployeeCommand(employee), CancellationToken.None); var allEmployees = await _mockEmployeeRepository.Object.GetAllAsync(); allEmployees.Count.ShouldBe(9); var updatedEmployee = await _mockEmployeeRepository.Object.GetByIdAsync(5); updatedEmployee.FirstName.ShouldBe("FirstName11"); updatedEmployee.MiddleName.ShouldBe("MiddleName11"); updatedEmployee.LastName.ShouldBe("LastName11"); }
public CreateEmployeeCommand(EmployeeRest employee) { FirstName = employee.FirstName; MiddleName = employee.MiddleName; LastName = employee.LastName; }