Exemplo n.º 1
0
        internal static IBudgetAccount ToDomain(this BudgetAccountModel budgetAccountModel, MapperCache mapperCache, IConverter accountingModelConverter)
        {
            NullGuard.NotNull(budgetAccountModel, nameof(budgetAccountModel))
            .NotNull(mapperCache, nameof(mapperCache))
            .NotNull(accountingModelConverter, nameof(accountingModelConverter));

            lock (mapperCache.SyncRoot)
            {
                IAccounting accounting = accountingModelConverter.Convert <AccountingModel, IAccounting>(budgetAccountModel.Accounting);

                return(budgetAccountModel.ToDomain(accounting, mapperCache, accountingModelConverter));
            }
        }
        private static IBudgetAccount ResolveBudgetAccount(BudgetAccountModel budgetAccountModel, IAccounting accounting, MapperCache mapperCache, IConverter accountingModelConverter)
        {
            NullGuard.NotNull(accounting, nameof(accounting))
            .NotNull(mapperCache, nameof(mapperCache))
            .NotNull(accountingModelConverter, nameof(accountingModelConverter));

            if (budgetAccountModel == null)
            {
                return(null);
            }

            IBudgetAccount budgetAccount = budgetAccountModel.Resolve(mapperCache.BudgetAccountDictionary) ?? budgetAccountModel.ToDomain(accounting, mapperCache, accountingModelConverter);

            if (accounting.BudgetAccountCollection.Contains(budgetAccount) == false)
            {
                accounting.BudgetAccountCollection.Add(budgetAccount);
            }

            return(budgetAccount);
        }