Ejemplo n.º 1
0
            /// <inheritdoc />
            public async Task <Unit> Handle(CreatePaymentCommand request, CancellationToken cancellationToken)
            {
                context.Entry(request.PaymentToSave).State = EntityState.Added;

                if (request.PaymentToSave.IsRecurring)
                {
                    context.Entry(request.PaymentToSave.RecurringPayment).State = EntityState.Added;
                }

                await context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
Ejemplo n.º 2
0
            public async Task <Unit> Handle(UpdatePaymentCommand request, CancellationToken cancellationToken)
            {
                Payment existingPayment = await context.Payments.FindAsync(request.Payment.Id);

                if (existingPayment != null)
                {
                    context.Entry(existingPayment).CurrentValues.SetValues(request.Payment);
                }

                await context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }