Example #1
0
        public IEnumerable <Transaction> Apply(TransactionEdit edit, bool ignoreMissingIds = true)
        {
            this.edits.Add(edit);

            // ReSharper disable once IteratorMethodResultIsIgnored
            return(this.ApplyInternal(edit, ignoreMissingIds));
        }
Example #2
0
        private IEnumerable <Transaction> FilterTransactions(TransactionEdit edit)
        {
            var filteredTransactions = this.AllParentChildTransactions.ToList();

            foreach (var scopeFilter in edit.ScopeFilters)
            {
                filteredTransactions = filteredTransactions.Where(t => FilterTransaction(scopeFilter, t)).ToList();
            }

            return(filteredTransactions);
        }
Example #3
0
        //This is kept internal because otherwise edit won't get tracked
        internal void ApplyEdit(TransactionEdit edit)
        {
            if (this.MergedEdit == null)
            {
                this.MergedEdit = new TransactionEdit.EditedValues(edit.Values);
                this.AppliedEditIdsDescending = new LinkedList <string>();
            }
            else
            {
                this.MergedEdit.Merge(edit.Values);
            }

            this.AppliedEditIdsDescending.AddItemFirst(edit.Id);

            this.CompleteUpdate();
        }
Example #4
0
        /// <summary>
        /// Assumes edit has already been added in this.edits collection
        /// </summary>
        private IEnumerable <Transaction> ApplyInternal(TransactionEdit edit, bool ignoreMissingIds = false)
        {
            var filteredTransactions = this.FilterTransactions(edit);
            var count = 0;

            foreach (var filteredTransaction in filteredTransactions)
            {
                filteredTransaction.ApplyEdit(edit);
                yield return(filteredTransaction);

                count++;
            }

            if (!ignoreMissingIds && edit.ScopeFilters.Length == 1 && edit.ScopeFilters[0].Type == TransactionEdit.ScopeType.TransactionId && count != edit.ScopeFilters[0].Parameters.Length)
            {
                throw new Exception("Edit targetted transactions with {0} IDs but only {1} were found in this collection".FormatEx(edit.ScopeFilters[0].Parameters.Length, count));
            }
        }
Example #5
0
 internal TransactionEdit(TransactionEdit edit)
     : this(edit.ScopeFilters, edit.SourceId, edit.Values)
 {
 }