Ejemplo n.º 1
0
        public async Task <Result <bool> > HandleAsync(RemovePaymentMethodCommand command, User currentUser, CancellationToken cancellationToken = default)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            if (currentUser == null)
            {
                return(FailureResult <bool> .Unauthorized());
            }

            if (currentUser.Role < Role.SystemAdmin)
            {
                return(FailureResult <bool> .Forbidden());
            }

            await paymentMethodRepository.RemoveAsync(command.PaymentMethodId, cancellationToken);

            return(SuccessResult <bool> .Create(true));
        }