Пример #1
0
        public long AddExpenseTransactionPaymentHistory(xPlug.BusinessObject.ExpenseTransactionPaymentHistory expenseTransactionPaymentHistory)
        {
            try
            {
                //Re-Map Object to Entity Object
                var myEntityObj = ExpenseTransactionPaymentHistoryMapper.Map <xPlug.BusinessObject.ExpenseTransactionPaymentHistory, ExpenseTransactionPaymentHistory>(expenseTransactionPaymentHistory);
                if (myEntityObj == null)
                {
                    return(-2);
                }
                using (var db = new ExpenseManagerDBEntities())
                {
                    db.AddToExpenseTransactionPaymentHistories(myEntityObj);
                    db.SaveChanges();
                    expenseTransactionPaymentHistory.ExpenseTransactionPaymentHistoryId = myEntityObj.ExpenseTransactionPaymentHistoryId;
                    var paymentVoucher = new BusinessObject.PaymentVoucherNumber
                    {
                        TransactionId          = expenseTransactionPaymentHistory.ExpenseTransactionPaymentHistoryId,
                        TransactionTotalAmount = expenseTransactionPaymentHistory.ExpenseTransaction.TotalApprovedAmount,
                        PaymentDate            = expenseTransactionPaymentHistory.PaymentDate,
                        DateSubmitted          = DateMap.GetLocalDate()
                    };
                    var pcvEntityObj = PaymentVoucherNumberMapper.Map <BusinessObject.PaymentVoucherNumber, PaymentVoucherNumber>(paymentVoucher);
                    db.AddToPaymentVoucherNumbers(pcvEntityObj);
                    db.SaveChanges();

                    return(expenseTransactionPaymentHistory.ExpenseTransactionPaymentHistoryId);
                }
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Пример #2
0
 public bool UpdateExpenseTransactionPaymentHistory(xPlug.BusinessObject.ExpenseTransactionPaymentHistory expenseTransactionPaymentHistory)
 {
     try
     {
         //Re-Map Object to Entity Object
         var myEntityObj = ExpenseTransactionPaymentHistoryMapper.Map <xPlug.BusinessObject.ExpenseTransactionPaymentHistory, ExpenseTransactionPaymentHistory>(expenseTransactionPaymentHistory);
         if (myEntityObj == null)
         {
             return(false);
         }
         using (var db = new ExpenseManagerDBEntities())
         {
             db.ExpenseTransactionPaymentHistories.Attach(myEntityObj);
             db.ObjectStateManager.ChangeObjectState(myEntityObj, EntityState.Modified);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return(false);
     }
 }