Skip to content

Instantly share code, notes, and snippets.

@rafaeldalsenter
Created April 8, 2020 21:34
Show Gist options
  • Save rafaeldalsenter/5b314569f43231553a375bb1f88d1cf4 to your computer and use it in GitHub Desktop.
Save rafaeldalsenter/5b314569f43231553a375bb1f88d1cf4 to your computer and use it in GitHub Desktop.
public class ClienteServices : IClienteServices
{
private readonly IMediator _mediator;
private readonly IMapper _mapper;
private readonly IClienteForQueryRepository _clienteForQueryRepository;
public ClienteServices(IMediator mediator,
IMapper mapper,
IClienteForQueryRepository clienteForQueryRepository)
{
_mapper = mapper;
_mediator = mediator;
_clienteForQueryRepository = clienteForQueryRepository;
}
public async Task<CommandReturnDto> Add(ClienteDto dto)
=> await _mediator.Send(_mapper.Map<CreateClienteCommand>(dto));
public async Task<CommandReturnDto> Delete(int id)
=> await _mediator.Send(new RemoveClienteCommand(id));
public ClienteDto GetById(int id)
=> _clienteForQueryRepository.GetById(id);
public async Task<CommandReturnDto> Update(ClienteDto dto)
=> await _mediator.Send(_mapper.Map<UpdateClienteCommand>(dto));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment