Пример #1
0
        protected override async Task <ContactAccountModel> OnDeleteAsync(ContactAccountModel contactAccountModel)
        {
            NullGuard.NotNull(contactAccountModel, nameof(contactAccountModel));

            await PostingLineModelHandler.DeleteAsync(contactAccountModel.PostingLines);

            return(await base.OnDeleteAsync(contactAccountModel));
        }
Пример #2
0
        protected override async Task <AccountModel> OnDeleteAsync(AccountModel accountModel)
        {
            NullGuard.NotNull(accountModel, nameof(accountModel));

            await PostingLineModelHandler.DeleteAsync(accountModel.PostingLines);

            await _creditInfoModelHandler.DeleteAsync(accountModel.CreditInfos);

            return(await base.OnDeleteAsync(accountModel));
        }
Пример #3
0
        protected override void OnDispose()
        {
            lock (SyncRoot)
            {
                EventPublisher.RemoveSubscriber(this);
            }

            AccountingModelHandler.Dispose();
            PostingLineModelHandler?.Dispose();
        }
Пример #4
0
        protected override async Task <BudgetAccountModel> OnDeleteAsync(BudgetAccountModel budgetAccountModel)
        {
            NullGuard.NotNull(budgetAccountModel, nameof(budgetAccountModel));

            await PostingLineModelHandler.DeleteAsync(budgetAccountModel.PostingLines);

            await _budgetInfoModelHandler.DeleteAsync(budgetAccountModel.BudgetInfos);

            return(await base.OnDeleteAsync(budgetAccountModel));
        }
Пример #5
0
        protected override async Task PrepareReadAsync(AccountingIdentificationState accountingIdentificationState)
        {
            NullGuard.NotNull(accountingIdentificationState, nameof(accountingIdentificationState));

            _accountingModel ??= await AccountingModelHandler.ForAsync(accountingIdentificationState.AccountingIdentifier);

            if (_includePostingLines == false || PostingLineModelHandler == null)
            {
                return;
            }

            _postingLineModelCollection ??= await PostingLineModelHandler.ForAsync(accountingIdentificationState.AccountingIdentifier);
        }
Пример #6
0
        protected AccountModelHandlerBase(RepositoryContext dbContext, IConverter modelConverter, IEventPublisher eventPublisher, DateTime statusDate, bool includePostingLines, PostingLineModelHandler postingLineModelHandler, bool fromPostingLineModelHandler)
            : base(dbContext, modelConverter)
        {
            NullGuard.NotNull(eventPublisher, nameof(eventPublisher));

            _includePostingLines = includePostingLines;

            EventPublisher              = eventPublisher;
            StatusDate                  = statusDate.Date;
            AccountingModelHandler      = new AccountingModelHandler(dbContext, modelConverter, EventPublisher, StatusDate, false, false);
            PostingLineModelHandler     = postingLineModelHandler;
            FromPostingLineModelHandler = fromPostingLineModelHandler;
            SyncRoot = new object();

            EventPublisher.AddSubscriber(this);
        }
Пример #7
0
        public AccountingModelHandler(RepositoryContext dbContext, IConverter modelConverter, IEventPublisher eventPublisher, DateTime statusDate, bool includeAccounts, bool includePostingLines)
            : base(dbContext, modelConverter)
        {
            NullGuard.NotNull(eventPublisher, nameof(eventPublisher));

            _eventPublisher      = eventPublisher;
            _statusDate          = statusDate.Date;
            _includeAccounts     = includeAccounts;
            _includePostingLines = includePostingLines;

            if (_includeAccounts)
            {
                _accountModelHandler        = new AccountModelHandler(dbContext, modelConverter, _eventPublisher, _statusDate, true, false);
                _budgetAccountModelHandler  = new BudgetAccountModelHandler(dbContext, modelConverter, _eventPublisher, _statusDate, true, false);
                _contactAccountModelHandler = new ContactAccountModelHandler(dbContext, modelConverter, _eventPublisher, _statusDate, false);
            }

            if (_includePostingLines)
            {
                _postingLineModelHandler = new PostingLineModelHandler(dbContext, modelConverter, _eventPublisher, DateTime.MinValue, _statusDate, false, false);
            }

            _eventPublisher.AddSubscriber(this);
        }
Пример #8
0
        private async Task <List <PostingLineModel> > OnReadAsync(TAccountModel accountModel, IReadOnlyCollection <PostingLineModel> postingLineModelCollection, PostingLineModelHandler postingLineModelHandler)
        {
            NullGuard.NotNull(accountModel, nameof(accountModel));

            if (postingLineModelCollection == null || postingLineModelHandler == null)
            {
                return(accountModel.PostingLines);
            }

            if (accountModel.PostingLines == null)
            {
                ExtractPostingLines(accountModel, postingLineModelCollection);
            }

            return((await postingLineModelHandler.ReadAsync(accountModel.PostingLines)).ToList());
        }
Пример #9
0
        private static async Task <List <PostingLineModel> > OnReadAsync(AccountingModel accountingModel, IReadOnlyCollection <PostingLineModel> postingLineModelCollection, AccountModelHandler accountModelHandler, BudgetAccountModelHandler budgetAccountModelHandler, ContactAccountModelHandler contactAccountModelHandler, PostingLineModelHandler postingLineModelHandler)
        {
            NullGuard.NotNull(accountingModel, nameof(accountingModel));

            if (postingLineModelCollection == null || postingLineModelHandler == null)
            {
                return(accountingModel.PostingLines);
            }

            foreach (AccountModel accountModel in accountingModel.Accounts ?? new List <AccountModel>(0))
            {
                if (accountModel.PostingLines == null)
                {
                    accountModel.ExtractPostingLines(postingLineModelCollection);
                }

                accountModel.PostingLines = (await postingLineModelHandler.ReadAsync(accountModel.PostingLines)).ToList();
                if (accountModel.PostingLines.Any() == false && accountModelHandler != null)
                {
                    accountModel.Deletable = await accountModelHandler.IsDeletableAsync(accountModel);
                }
            }

            foreach (BudgetAccountModel budgetAccountModel in accountingModel.BudgetAccounts ?? new List <BudgetAccountModel>(0))
            {
                if (budgetAccountModel.PostingLines == null)
                {
                    budgetAccountModel.ExtractPostingLines(postingLineModelCollection);
                }

                budgetAccountModel.PostingLines = (await postingLineModelHandler.ReadAsync(budgetAccountModel.PostingLines)).ToList();
                if (budgetAccountModel.PostingLines.Any() == false && budgetAccountModelHandler != null)
                {
                    budgetAccountModel.Deletable = await budgetAccountModelHandler.IsDeletableAsync(budgetAccountModel);
                }
            }

            foreach (ContactAccountModel contactAccountModel in accountingModel.ContactAccounts ?? new List <ContactAccountModel>(0))
            {
                if (contactAccountModel.PostingLines == null)
                {
                    contactAccountModel.ExtractPostingLines(postingLineModelCollection);
                }

                contactAccountModel.PostingLines = (await postingLineModelHandler.ReadAsync(contactAccountModel.PostingLines)).ToList();
                if (contactAccountModel.PostingLines.Any() == false && contactAccountModelHandler != null)
                {
                    contactAccountModel.Deletable = await contactAccountModelHandler.IsDeletableAsync(contactAccountModel);
                }
            }

            if (accountingModel.PostingLines == null)
            {
                accountingModel.ExtractPostingLines(postingLineModelCollection);
            }

            return((await postingLineModelHandler.ReadAsync(accountingModel.PostingLines)).ToList());
        }