Ejemplo n.º 1
0
        public int CreateTransaction(beTransaction transEntity)
        {
            using (var scope = new TransactionScope())
            {
                var transaction = new BankTransaction
                {
                    Id                 = new int(),
                    AccountId          = transEntity.AccountId,
                    Amount             = transEntity.Amount,
                    CategoryId         = transEntity.CategoryId,
                    Date               = transEntity.Date,
                    Description        = transEntity.Description,
                    IsSplitTransaction = transEntity.IsSplitTransaction,
                    Note               = transEntity.Note,
                    ParentId           = transEntity.ParentId,
                    Payee              = transEntity.Payee,
                    ReferenceId        = transEntity.ReferenceId,
                    TxSource           = transEntity.TxSource,
                    Type               = transEntity.Type,
                    UserId             = transEntity.UserId
                };

                _unitOfWork.TransactionRepository.Insert(transaction);
                _unitOfWork.Save();
                scope.Complete();
                return(transaction.Id);
            }
        }
Ejemplo n.º 2
0
        public bool UpdateTransaction(int transId, beTransaction transEntity)
        {
            var success = false;

            if (transEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var transaction = _unitOfWork.TransactionRepository.GetById(transEntity);
                    if (transaction != null)
                    {
                        transaction.Description = transEntity.Description;
                        transaction.CategoryId  = transEntity.CategoryId;
                        _unitOfWork.TransactionRepository.Update(transaction);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }