Exemplo n.º 1
0
        public async Task <bool> Handle(DeletePaymentMethodCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var record = await _context.PaymentMethods
                             .SingleOrDefaultAsync(a => a.ID == request.PaymentMethodID && a.CustomerID == request.CustomerID);

                if (record != null)
                {
                    _stripe.DetachPaymentMethod(record.StripePaymentMethodID);
                    _context.PaymentMethods.Remove(record);
                    await _context.SaveChangesAsync(cancellationToken);

                    return(true);
                }
            }
            catch (Exception)
            {
            }
            return(true);
        }