Пример #1
0
        //TODO: payment.CreatedByID = Account.GetCurrentUser().ID; before edit payment
        public void Edit(D.Payment payment)
        {
            EF.Payment efpayment = ConverToEFwithID(payment);

            var tempPayment = _context.Payments.Single(a => a.PaymentID == efpayment.PaymentID);

            tempPayment.PaymentID     = efpayment.PaymentID;
            tempPayment.Name          = efpayment.Name;
            tempPayment.Amount        = efpayment.Amount;
            tempPayment.BeneficiaryID = efpayment.BeneficiaryID;
            tempPayment.CurrencyID    = efpayment.CurrencyID;
            tempPayment.Locked        = efpayment.Locked;
            tempPayment.Email         = efpayment.Email;
            //tempPayment.CreatedDate = efpayment.CreatedDate;
            //tempPayment.PaymentDate = efpayment.PaymentDate;
            tempPayment.ModifiedDate    = efpayment.ModifiedDate;
            tempPayment.PublishDate     = efpayment.PublishDate;
            tempPayment.CreatedByID     = efpayment.CreatedByID;
            tempPayment.ModifiedByID    = efpayment.ModifiedByID;
            tempPayment.PaymentSourceID = efpayment.PaymentSourceID;
            tempPayment.PaymentTypeID   = efpayment.PaymentTypeID;
            tempPayment.OptOut          = efpayment.OptOut;

            _context.SaveChanges();
        }
Пример #2
0
        private D.Payment ConvertToDomain(EF.Payment efPayment)
        {
            EF.Beneficiary efBeneficiary = _context.Beneficiaries.FirstOrDefault(b => b.BeneficiaryID == efPayment.BeneficiaryID);
            EF.Currency    efCurrency    = _context.Currencies.FirstOrDefault(c => c.CurrencyID == efPayment.CurrencyID);

            D.Beneficiary beneficiary = new D.Beneficiary(efBeneficiary.Name, efBeneficiary.Description);
            D.Currency    currency    = new D.Currency(efCurrency.CurrencyCode, efCurrency.Ratio, efCurrency.ExchangeRate);

            D.PaymentSource source = new D.PaymentSource(efPayment.PaymentSource.Source);
            D.PaymentType   type   = new D.PaymentType(efPayment.PaymentType.Type);

            string createdBy  = _context.Accounts.FirstOrDefault(b => b.AccountID == efPayment.CreatedByID).UserName;
            string modifiedBy = "";

            if (efPayment.ModifiedByID > 0)
            {
                modifiedBy = _context.Accounts.FirstOrDefault(b => b.AccountID == efPayment.ModifiedByID).UserName;
            }

            return(new D.Payment(efPayment.PaymentID, efPayment.Name, efPayment.Amount, currency, beneficiary, efPayment.Locked,
                                 efPayment.Email, efPayment.CreatedDate, efPayment.ModifiedDate, efPayment.PaymentDate, efPayment.PublishDate, createdBy, modifiedBy, source, type, efPayment.OptOut));
        }
Пример #3
0
 //TODO: payment.CreatedByID = Account.GetCurrentUser().ID; before edit payment
 public void Edit(D.Payment payment)
 {
     EF.Payment efpayment = ConverToEFwithID(payment);
     _context.Entry(efpayment).State = EntityState.Modified;
     _context.SaveChanges();
 }