Exemple #1
0
        // TODO 3c: Query is more complex.
        public static decimal GetAccountBalance(string account, DateTime snapshotDate, DateTime closingDate, CAP_EventSourcingEntities entities)
        {
            AccountBalance        snapshot      = GetSnapshot(account, snapshotDate, entities);
            IQueryable <decimal?> transfersFrom =
                from t in entities.Transfers
                where
                t.From == account &&
                t.DateOfBusiness > snapshotDate &&
                t.DateOfBusiness <= closingDate
                select(decimal?) t.Amount;

            IQueryable <decimal?> transfersTo =
                from t in entities.Transfers
                where
                t.To == account &&
                t.DateOfBusiness > snapshotDate &&
                t.DateOfBusiness <= closingDate
                select(decimal?) t.Amount;

            return(snapshot.Balance - (transfersFrom.Sum() ?? 0.0m) + (transfersTo.Sum() ?? 0.0m));
        }
Exemple #2
0
 /// <summary>
 /// Create a new AccountBalance object.
 /// </summary>
 /// <param name="account">Initial value of the Account property.</param>
 /// <param name="dateOfBusiness">Initial value of the DateOfBusiness property.</param>
 /// <param name="balance">Initial value of the Balance property.</param>
 public static AccountBalance CreateAccountBalance(global::System.String account, global::System.DateTime dateOfBusiness, global::System.Decimal balance)
 {
     AccountBalance accountBalance = new AccountBalance();
     accountBalance.Account = account;
     accountBalance.DateOfBusiness = dateOfBusiness;
     accountBalance.Balance = balance;
     return accountBalance;
 }
Exemple #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the AccountBalances EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAccountBalances(AccountBalance accountBalance)
 {
     base.AddObject("AccountBalances", accountBalance);
 }
Exemple #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the AccountBalances EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAccountBalances(AccountBalance accountBalance)
 {
     base.AddObject("AccountBalances", accountBalance);
 }