Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. public abstract class CriacaoTarefaHandler : ICriacaoTarefaHandler
  2. {
  3. protected ICriacaoTarefaHandler _sucessor;
  4. protected readonly IRepositorioConfiguracao _repositorioConfiguracao;
  5. protected readonly ITarefaConferenciaServico _tarefaConferenciaServico;
  6.  
  7. protected CriacaoTarefaHandler(IRepositorioConfiguracao repositorioConfiguracao, ITarefaConferenciaServico tarefaConferenciaServico)
  8. {
  9. _repositorioConfiguracao = repositorioConfiguracao;
  10. _tarefaConferenciaServico = tarefaConferenciaServico;
  11. }
  12.  
  13. public async Task Handle(TarefaDto tarefaDto)
  14. {
  15. var criouTarefa = await TrataCriacaoTarefa(tarefaDto);
  16.  
  17. if (criouTarefa)
  18. return;
  19.  
  20. if (_sucessor != null)
  21. {
  22. await _sucessor.Handle(tarefaDto);
  23. }
  24. }
  25.  
  26. public void AtribuirSucessor(ICriacaoTarefaHandler successor)
  27. {
  28. _sucessor = successor;
  29. }
  30.  
  31. protected abstract Task<bool> TrataCriacaoTarefa(TarefaDto tarefaDto);
  32.  
  33. protected async Task<Configuracao> ObterConfiguracao(TarefaDto tarefaDto)
  34. {
  35. return await _repositorioConfiguracao.ObterPorIdAsync(tarefaDto.IdArmazem);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement