public async Task <TitherModel> Handle(GetTitherQuery request, CancellationToken cancellationToken) { var tither = await _titherRepository.GetByIdAsync(request.Id); var result = (tither != null && tither.Deleted == false) ? _mapper.Map <TitherModel>(tither) : null; return(await Task.FromResult(result)); }
public async Task <bool> Handle(UpdateTitherCommand request, CancellationToken cancellationToken) { var titherFromRepo = await _titherRepository.GetByIdAsync(request.Id); _mapper.Map(request.parameters, titherFromRepo); if (!titherFromRepo.Validate(titherFromRepo, new TitherValidator())) { _notificationContext.AddNotifications(titherFromRepo.ValidationResult); return(false); } _titherRepository.Edit(titherFromRepo); return(true); }
public async Task <bool> Handle(DeleteTitherCommand request, CancellationToken cancellationToken) { var tither = await _titherRepository.GetByIdAsync(request.Id); if (tither == null) { _notificationContext.AddNotification("NotFound", "Dizimista não encontrado"); return(false); } tither.Delete(); _titherRepository.Edit(tither); return(true); }