internal static IContactAccount ToDomain(this ContactAccountModel contactAccountModel, MapperCache mapperCache, IConverter accountingModelConverter)
        {
            NullGuard.NotNull(contactAccountModel, nameof(contactAccountModel))
            .NotNull(mapperCache, nameof(mapperCache))
            .NotNull(accountingModelConverter, nameof(accountingModelConverter));

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

                return(contactAccountModel.ToDomain(accounting, mapperCache, accountingModelConverter));
            }
        }
        private static IContactAccount ResolveContactAccount(ContactAccountModel contactAccountModel, IAccounting accounting, MapperCache mapperCache, IConverter accountingModelConverter)
        {
            NullGuard.NotNull(accounting, nameof(accounting))
            .NotNull(mapperCache, nameof(mapperCache))
            .NotNull(accountingModelConverter, nameof(accountingModelConverter));

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

            IContactAccount contactAccount = contactAccountModel.Resolve(mapperCache.ContactAccountDictionary) ?? contactAccountModel.ToDomain(accounting, mapperCache, accountingModelConverter);

            if (accounting.ContactAccountCollection.Contains(contactAccount) == false)
            {
                accounting.ContactAccountCollection.Add(contactAccount);
            }

            return(contactAccount);
        }