private static PaymentMethod FromRow(PaymentMethodRow row)
 {
     return(new PaymentMethod(new PaymentMethodId(row.Id),
                              row.Name,
                              row.Description
                              ));
 }
        public Task StoreAsync(PaymentMethod paymentMethod, CancellationToken cancellationToken = default)
        {
            return(Task.Factory.StartNew(() =>
            {
                var dbSet = dbContext.PaymentMethods;

                var row = dbSet.FirstOrDefault(x => x.Id == paymentMethod.Id.Value);
                if (row != null)
                {
                    ToRow(paymentMethod, row);
                    dbSet.Update(row);
                }
                else
                {
                    row = new PaymentMethodRow();
                    ToRow(paymentMethod, row);
                    dbSet.Add(row);
                }

                dbContext.SaveChanges();
            }, cancellationToken));
        }
 private static void ToRow(PaymentMethod obj, PaymentMethodRow row)
 {
     row.Id          = obj.Id.Value;
     row.Name        = obj.Name;
     row.Description = obj.Description;
 }