Beispiel #1
0
        /// <summary>
        /// (Re)initialization to provide initial values not derived from events
        /// </summary>
        /// <param name="budgetListRepository">budget list repository</param>
        /// <param name="budgetListItemRepository">budget list item repository</param>
        /// <param name="accountListRepository">account list repository</param>
        /// <param name="commandBus">Command bus</param>
        private void Init(
            BudgetListRepository budgetListRepository,
            BudgetListItemRepository budgetListItemRepository,
            AccountListRepository accountListRepository,
            ICommandBus commandBus)
        {
            // Init with "off-budget" budget
            var list = this.GetBudgetList();
            var offBudgetAccountList = new AccountList();
            var offBudget            = new BudgetListItem(
                BudgetId.OffBudgetId,
                "Off-budget",
                null,
                offBudgetAccountList,
                commandBus);

            list.Add(offBudget);
            accountListRepository.Save(offBudget.BudgetId, offBudgetAccountList);
            budgetListItemRepository.Save(offBudget);
            budgetListRepository.Save(list);
        }
Beispiel #2
0
        /// <summary>
        /// Initialises a new instance of the <see cref="BudgetListProjection"/> class.
        /// </summary>
        /// <param name="budgetListRepository">Budget list repository to use</param>
        /// <param name="budgetListItemRepository">Budget list item repository to use</param>
        /// <param name="accountListRepository">Account list repository to use</param>
        /// <param name="accountListItemRepository">Account list item repository to use</param>
        /// <param name="commandBus">Command bus</param>
        /// <param name="readStoreResetBroadcast">Read store reset broadcast</param>
        public BudgetListProjection(
            BudgetListRepository budgetListRepository,
            BudgetListItemRepository budgetListItemRepository,
            AccountListRepository accountListRepository,
            AccountListItemRepository accountListItemRepository,
            ICommandBus commandBus,
            IReadStoreResetBroadcast readStoreResetBroadcast)
        {
            this.budgetListRepository      = budgetListRepository;
            this.budgetListItemRepository  = budgetListItemRepository;
            this.accountListRepository     = accountListRepository;
            this.accountListItemRepository = accountListItemRepository;
            this.commandBus = commandBus;

            readStoreResetBroadcast.ReadStoreReset +=
                (sender, args) =>
            {
                this.Init(budgetListRepository, budgetListItemRepository, accountListRepository, commandBus);
            };

            this.Init(budgetListRepository, budgetListItemRepository, accountListRepository, commandBus);
        }