Ejemplo n.º 1
0
        public AccountingLib.Models.account Create(int ownerEntityId,int currencyID,decimal balance=0)
        {
            using (var ctx = new AccContexts())
            {
                var duplicate = ctx.account
                    .Where(x => x.ownerEntityID == ownerEntityId && x.currencyID == currencyID && x.catTypeID == CATTYPE)
                    .SingleOrDefault();
                if (duplicate != null)
                    ctx.DeleteObject(duplicate);
                var newAccount = new account()
                {
                    catTypeID=CATTYPE,
                    ownerEntityID=ownerEntityId,
                    currencyID=currencyID,
                    balance=balance
                };
                ctx.account.AddObject(newAccount);
                ctx.SaveChanges();

                return newAccount;
            }
        }
 /// <summary>
 /// Create a new account object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="balance">Initial value of the balance property.</param>
 public static account Createaccount(global::System.Int32 id, global::System.Decimal balance)
 {
     account account = new account();
     account.ID = id;
     account.balance = balance;
     return account;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the account EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToaccount(account account)
 {
     base.AddObject("account", account);
 }