Beispiel #1
0
        public EmployeeDeleteResponse Handle(EmployeeDeleteCommand command)
        {
            var employee = _employeeContext.Employees.FirstOrDefault(e => e.Id == command.Id);

            if (employee == null)
            {
                return(ResponseFactory.Failure <EmployeeDeleteResponse>(EmployeeError.EmployeeDoesntExist));
            }

            _employeeContext.Employees.Remove(employee);

            return(ResponseFactory.Success <EmployeeDeleteResponse>());
        }
            public void should_handle_delete_employee_command()
            {
                // Arrange
                var inputCommand =
                    new EmployeeDeleteCommand(anyEmployee.EmployeeId);

                EmployeeRepositoryMock
                .Setup(i => i.ReadAsync(It.IsAny <Guid>()))
                .ReturnsAsync(anyEmployee);

                // Act
                var result = EmployeeDeleteCommandHandlerUnderTest.Handle(inputCommand, default(CancellationToken)).Result;

                // Assert
                Assert.Equal(Unit.Value, result);
            }
 public Task <string> Handle(EmployeeDeleteCommand request, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }
 public void RemoveEmployee(EmployeeDeleteCommand command)
 {
     CommandBus.Dispatch(command);
 }
Beispiel #5
0
        public async Task <IActionResult> Delete(EmployeeDeleteCommand command)
        {
            string result = await _mediator.Send(command);

            return(Ok(result));
        }
 public void RemoveEmployee(EmployeeDeleteCommand command)
 {
     commandFacade.RemoveEmployee(command);
 }