Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        public Payment(int paymentID, string name, decimal amount, Currency currency, Beneficiary beneficiary, bool locked,
                       string email, DateTime createdDate, DateTime?modifiedDate, DateTime paymentDate, DateTime?publishDate, string createdBy, string modifiedBy, PaymentSource source, PaymentType type,
                       bool optOut)
        {
            if (paymentID < 0)
            {
                throw new ArgumentNullException("Payment:paymentID");
            }
            PaymentID = paymentID;
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("Payment:name");
            }
            Name = name;
            if (amount < 0)
            {
                throw new ArgumentNullException("Payment:amount");
            }
            Amount = amount;
            if (currency == null)
            {
                throw new ArgumentNullException("Payment:currency");
            }
            Currency = currency;
            if (beneficiary == null)
            {
                throw new ArgumentNullException("Payment:beneficiary");
            }
            Beneficiary = beneficiary;

            // added
            if (string.IsNullOrEmpty(email))
            {
                throw new ArgumentNullException("Payment:email");
            }
            Email = email;
            if (createdDate == null)
            {
                throw new ArgumentNullException("Payment:createdDate");
            }
            CreatedDate = createdDate;
            if (paymentDate == null)
            {
                throw new ArgumentNullException("Payment:paymentDate");
            }
            PaymentDate = paymentDate;
            if (string.IsNullOrEmpty(createdBy))
            {
                throw new ArgumentNullException("Payment:createdBy");
            }
            CreatedBy = createdBy;
            if (source == null)
            {
                throw new ArgumentNullException("Payment:source");
            }
            Source = source;
            if (type == null)
            {
                throw new ArgumentNullException("Payment:type");
            }
            Type         = type;
            Locked       = locked;
            OptOut       = optOut;
            ModifiedDate = modifiedDate;
            PublishDate  = publishDate;
            ModifiedBy   = modifiedBy;
        }