Пример #1
0
        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);
        }
Пример #2
0
        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));
        }