Пример #1
0
        public void PreauthorizeWalletCredit(DBConstant.EOperator optor, DBConstant.ETransactionType type, decimal amount, string docCode, Guid walletId)
        {
            var sType      = Enum.GetName(type.GetType(), type);
            var userWallet = _uow.Repository <UserWallet>().GetByKey(walletId);

            Preauth newAuth = new Preauth
            {
                WalletId        = userWallet.WalletId,
                ReferenceNo     = docCode,
                TransactionDate = DateTime.UtcNow,
                TransactionType = sType,
                StatusId        = (int)EStatus.Pending
            };

            switch (optor)
            {
            case DBConstant.EOperator.ADD:
                newAuth.Credit = amount;
                break;

            case DBConstant.EOperator.DEDUCT:
                newAuth.Debit = amount;
                userWallet.AuthorizedBalance += amount;
                userWallet.Balance           -= amount;
                break;

            default:
                break;
            }

            _uow.Repository <Preauth>().Insert(newAuth);
            _uow.Repository <UserWallet>().Update(userWallet);
        }
Пример #2
0
        public void TransactWalletCredit(DBConstant.EOperator optor, DBConstant.ETransactionType type, decimal amount, string docCode, Guid walletId)
        {
            var sType                = Enum.GetName(type.GetType(), type);
            var userWallet           = _uow.Repository <UserWallet>().GetByKey(walletId);
            var newWalletTransaction = new WalletTransaction();

            switch (optor)
            {
            case DBConstant.EOperator.ADD:
                userWallet.Balance  += amount;
                newWalletTransaction = new WalletTransaction
                {
                    WalletId        = walletId,
                    ReferenceNo     = docCode,
                    TransactionDate = DateTime.UtcNow,
                    Credit          = amount,
                    TransactionType = sType
                };

                break;

            case DBConstant.EOperator.DEDUCT:
                userWallet.AuthorizedBalance -= amount;
                newWalletTransaction          = new WalletTransaction
                {
                    WalletId        = walletId,
                    ReferenceNo     = docCode,
                    TransactionDate = DateTime.UtcNow,
                    Debit           = amount,
                    TransactionType = sType
                };
                break;

            default:
                break;
            }

            _uow.Repository <WalletTransaction>().Insert(newWalletTransaction);
            _uow.Repository <UserWallet>().Update(userWallet);
        }