/// <summary>
 /// Saves the accounts.
 /// </summary>
 /// <param name="accounts">The accounts.</param>
 /// <param name="yodleeUserName">Name of the yodlee user.</param>
 /// <param name="yodleeUserPassword">The yodlee user password.</param>
 /// <exception cref="System.InvalidOperationException">could not save account</exception>
 private void SaveAccounts(IList <YodleeContentServiceAccount> accounts, string yodleeUserName, string yodleeUserPassword)
 {
     foreach (var userAccount in accounts)
     {
         var res = YodleeQueries.UpsertContentServiceAccount(ConvertToOrderItem(userAccount));
         if (!res.HasValue || !res.Value)
         {
             throw new InvalidOperationException("could not save account");
         }
     }
 }
        /// <summary>
        /// Handles a message.
        /// </summary>
        /// <param name="message">The message to handle.</param>
        /// <remarks>
        /// This method will be called when a message arrives on the bus and should contain
        ///             the custom logic to execute when the message is received.
        /// </remarks>
        public void Handle(YodleeGetTransactionsCommandResponse message)
        {
            foreach (IGrouping <int, YodleeTransaction> group in message.Transactions.GroupBy(t => t.AccountId))
            {
                YodleeOrderItem account = new YodleeOrderItem
                {
                    accountNumber = group.First()
                                    .AccountNumber,
                    bankAccountId = group.Key
                };

                YodleeQueries.UpsertContentServiceAccount(account);

                YodleeQueries.UpsertTransactions(group.Select(ConvertToYodleeOrderItemTransaction));
            }
        }