Пример #1
0
        public static PaymentItem ToDomain(this PaymentItemDTO paymentItem, PaymentItem originalPaymentItem = null)
        {
            if (originalPaymentItem != null && originalPaymentItem.ID == paymentItem.ID)
            {
                originalPaymentItem.SequenceNo  = paymentItem.SequenceNo;
                originalPaymentItem.PaymentID   = paymentItem.PaymentID;
                originalPaymentItem.Description = paymentItem.Description;
                originalPaymentItem.Amount      = paymentItem.Amount;
                originalPaymentItem.InvoiceID   = paymentItem.InvoiceID;
                originalPaymentItem.InvoiceNo   = paymentItem.InvoiceNo;
                originalPaymentItem.CreateDate  = paymentItem.CreateDate;
                originalPaymentItem.ChangeDate  = paymentItem.ChangeDate;

                return(originalPaymentItem);
            }

            return(new PaymentItem()
            {
                ID = paymentItem.ID,
                SequenceNo = paymentItem.SequenceNo,
                PaymentID = paymentItem.PaymentID,
                Description = paymentItem.Description,
                Amount = paymentItem.Amount,
                InvoiceID = paymentItem.InvoiceID,
                InvoiceNo = paymentItem.InvoiceNo,
                Concurrency = paymentItem.Concurrency,
                CreateDate = paymentItem.CreateDate,
                ChangeDate = paymentItem.ChangeDate
            });
        }
Пример #2
0
        public static object ToDataShapeObject(this PaymentItemDTO paymentItem, List <string> lstOfFields)
        {
            if (!lstOfFields.Any())
            {
                return(paymentItem);
            }
            else
            {
                ExpandoObject objectToReturn = new ExpandoObject();
                foreach (var field in lstOfFields)
                {
                    var fieldValue = paymentItem.GetType()
                                     .GetProperty(field, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance)
                                     .GetValue(paymentItem, null);

                    ((IDictionary <string, object>)objectToReturn).Add(field, fieldValue);
                }
                return(objectToReturn);
            }
        }