예제 #1
0
        public async Task <IOperationResult> HandleAsync(IDeletePayment command, ICorrelationContext context)
        {
            var payment = await _paymentsRepository.GetAsync(command.Id);

            if (payment is null)
            {
                throw new BaristaException("payment_not_found", $"Could not find payment with ID '{command.Id}'");
            }

            await _paymentsRepository.DeleteAsync(payment);

            await _paymentsRepository.SaveChanges();

            await _busPublisher.Publish(new PaymentDeleted(command.Id));

            return(OperationResult.Ok());
        }