/// <summary>
 /// Converts a <see cref="PaymentRequestEntity"/> to a <see cref="InputPaymentRequest"/>.
 /// </summary>
 /// <param name="paymentRequest">The entity.</param>
 /// <returns>The converted object.</returns>
 public static InputPaymentRequest ToInput(this PaymentRequestEntity paymentRequest)
 {
     return(new InputPaymentRequest
     {
         Id = paymentRequest.Id,
         Amount = paymentRequest.Amount,
         Count = paymentRequest.Count,
         Name = paymentRequest.Name,
     });
 }
Esempio n. 2
0
 /// <summary>
 /// Converts the entity to a data transfer object.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <returns>The data transfer object.</returns>
 public static PaymentRequest AsPaymentRequest(this PaymentRequestEntity entity)
 {
     return(new PaymentRequest
     {
         Id = entity.Id,
         Name = entity.Name,
         Amount = entity.Amount,
         Count = entity.Count,
         PaidCount = entity.PaidCount,
         TransactionId = entity.TransactionId,
         AmountDue = (entity.Count - entity.PaidCount) * entity.Amount,
         Complete = entity.PaidCount == entity.Count,
     });
 }
        public async Task CreatePaymentRequestAsync(Guid paymentRequestId, string voucherShortCode)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var paymentRequest = new PaymentRequestEntity
                {
                    Id = paymentRequestId,
                    VoucherShortCode = voucherShortCode,
                };

                context.PaymentRequests.Add(paymentRequest);

                await context.SaveChangesAsync();
            }
        }