public async Task <TitheModel> Handle(GetTitheQuery request, CancellationToken cancellationToken) { var tithe = await _titheRepository.GetByIdAsync(request.Id); var result = (tithe != null && tithe.Deleted == false) ? _mapper.Map <TitheModel>(tithe) : null; return(await Task.FromResult(result)); }
public async Task <bool> Handle(DeleteTitheCommand request, CancellationToken cancellationToken) { var tithe = await _titheRepository.GetByIdAsync(request.Id); if (tithe == null) { _notificationContext.AddNotification("NotFound", "Contribuição não encontrada"); return(false); } tithe.Delete(); _titheRepository.Edit(tithe); return(true); }
public async Task <bool> Handle(UpdateTitheCommand request, CancellationToken cancellationToken) { var titheFromRepo = await _titheRepository.GetByIdAsync(request.Id); _mapper.Map(request.parameters, titheFromRepo); if (!titheFromRepo.Validate(titheFromRepo, new TitheValidator())) { _notificationContext.AddNotifications(titheFromRepo.ValidationResult); return(await Task.FromResult(false)); } _titheRepository.Edit(titheFromRepo); return(await Task.FromResult(true)); }