Exemple #1
0
        public async Task <Unit> Handle(CreateCreditCard request, CancellationToken cancellationToken)
        {
            if (!await _subscriptionRepo.ExistsAsync(request.CreditCardSubscriptionId))
            {
                throw new InvalidOperationException("Can not create a card with non existing subscription");
            }
            var card = new CreditCard(request.CreditCardId, request.CreditCardSubscriptionId, request.Occured);

            await SaveAsync(card, -1);

            return(Unit.Value);
        }
Exemple #2
0
 public CreateCreditCardModelValidator(IAggregateRepository <CreditCardSubscription> repo)
 {
     RuleFor(x => x.CreditCardSubscriptionId)
     .MustAsync((x, token) => repo.ExistsAsync(new CreditCardSubscriptionId(x)))
     .WithMessage("Subscription does not exist");
 }