Exemplo n.º 1
0
        protected void addWalletMoney(decimal amount, string title, int currencyID)
        {
            using (var ts = new TransactionScope())
                using (var ctx = new AccountingLib.Models.AccContexts())
                {
                    //Record related transctions
                    List <int> transactions = new List <int>();
                    var        trans1       = Transaction.createNew(this.ENTITYID, (int)AssetCategories.W, +1 * (decimal)amount, currencyID);
                    transactions.Add(trans1);
                    var trans2 = Transaction.createNew(this.ENTITYID, (int)AssetCategories.CCCASH, -1 * (decimal)amount, currencyID);
                    transactions.Add(trans2);

                    //Record Wallet entity and walletEntityTransaction
                    var entityWallet = new AccountingLib.Models.entityWallet()
                    {
                        entityID   = this.ENTITYID,
                        amount     = amount,
                        title      = title,
                        currencyID = currencyID
                    };
                    ctx.entityWallet.AddObject(entityWallet);
                    ctx.SaveChanges();

                    foreach (var txn in transactions)
                    {
                        var entityWalletTxn = new AccountingLib.Models.entityWalletTransaction()
                        {
                            entityWalletID = entityWallet.ID,
                            transactionID  = txn
                        };
                        ctx.entityWalletTransaction.AddObject(entityWalletTxn);
                        ctx.SaveChanges();
                    }

                    ts.Complete();
                }
        }
 /// <summary>
 /// Create a new entityWallet object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static entityWallet CreateentityWallet(global::System.Int32 id)
 {
     entityWallet entityWallet = new entityWallet();
     entityWallet.ID = id;
     return entityWallet;
 }
Exemplo n.º 3
0
        protected void addWalletMoney(decimal amount, string title, int currencyID)
        {
            using(var ts=new TransactionScope())
            using(var ctx=new AccountingLib.Models.AccContexts())
            {
                //Record related transctions
                List<int> transactions = new List<int>();
                var trans1 = Transaction.createNew(this.ENTITYID, (int)AssetCategories.W, +1 * (decimal)amount, currencyID);
                transactions.Add(trans1);
                var trans2 = Transaction.createNew(this.ENTITYID, (int)AssetCategories.CCCASH, -1 * (decimal)amount, currencyID);
                transactions.Add(trans2);

                //Record Wallet entity and walletEntityTransaction
                var entityWallet = new AccountingLib.Models.entityWallet()
                {
                    entityID=this.ENTITYID,
                    amount=amount,
                    title=title,
                    currencyID=currencyID
                };
                ctx.entityWallet.AddObject(entityWallet);
                ctx.SaveChanges();

                foreach(var txn in transactions)
                {
                    var entityWalletTxn = new AccountingLib.Models.entityWalletTransaction()
                    {
                        entityWalletID = entityWallet.ID,
                        transactionID = txn
                    };
                    ctx.entityWalletTransaction.AddObject(entityWalletTxn);
                    ctx.SaveChanges();
                }

                ts.Complete();
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the entityWallet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToentityWallet(entityWallet entityWallet)
 {
     base.AddObject("entityWallet", entityWallet);
 }