} // End ToModel Method

        public virtual LedgerBookDto ToDto(LedgerBook model)
        {
            ToDtoPreprocessing(model);
            LedgerBookDto dto = null;

            DtoFactory(ref dto, model);
            if (dto == null)
            {
                dto = new LedgerBookDto();
            }
            var mapper3  = new Mapper_LedgerBucketDto_LedgerBucket(this.bucketRepo, this.accountTypeRepo, this.bucketFactory);
            var ledgers7 = model.Ledgers.Select(mapper3.ToDto).ToList();

            dto.Ledgers = ledgers7;
            var modified8 = model.Modified;

            dto.Modified = modified8;
            var name9 = model.Name;

            dto.Name = name9;
            var mapper4           = new Mapper_LedgerEntryLineDto_LedgerEntryLine(this.accountTypeRepo, this.bucketFactory, this.transactionFactory);
            var reconciliations10 = model.Reconciliations.Select(mapper4.ToDto).ToList();

            dto.Reconciliations = reconciliations10;
            var storageKey11 = model.StorageKey;

            dto.StorageKey = storageKey11;
            var mapper5 = new Mapper_MobileSettingsDto_MobileSettings();

            dto.MobileSettings = mapper5.ToDto(model.MobileSettings);

            ToDtoPostprocessing(ref dto, model);
            return(dto);
        } // End ToDto Method
 public void TestInitialise()
 {
     var bucketRepo = new BucketBucketRepoAlwaysFind();
     var accountRepo = new InMemoryAccountTypeRepository();
     var subject = new Mapper_LedgerBucketDto_LedgerBucket(bucketRepo, accountRepo, new LedgerBucketFactory(bucketRepo, accountRepo));
     Result = subject.ToDto(TestData);
 }
        public virtual LedgerBook ToModel(LedgerBookDto dto)
        {
            ToModelPreprocessing(dto);
            LedgerBook model = null;

            ModelFactory(dto, ref model);
            if (model == null)
            {
                var constructors = typeof(LedgerBook).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance);
                var constructor  = constructors.First(c => c.GetParameters().Length == 0);
                model = (LedgerBook)constructor.Invoke(new Type[] { });
            }
            var modelType = model.GetType();
            var mapper1   = new Mapper_LedgerBucketDto_LedgerBucket(this.bucketRepo, this.accountTypeRepo, this.bucketFactory);
            var ledgers1  = dto.Ledgers.Select(mapper1.ToModel).ToList();

            modelType.GetProperty("Ledgers").SetValue(model, ledgers1);
            var modified2 = dto.Modified;

            modelType.GetProperty("Modified").SetValue(model, modified2);
            var name3 = dto.Name;

            modelType.GetProperty("Name").SetValue(model, name3);
            var mapper2          = new Mapper_LedgerEntryLineDto_LedgerEntryLine(this.accountTypeRepo, this.bucketFactory, this.transactionFactory);
            var reconciliations4 = dto.Reconciliations.Select(mapper2.ToModel).ToList();

            modelType.GetProperty("Reconciliations").SetValue(model, reconciliations4);
            var storageKey5 = dto.StorageKey;

            modelType.GetProperty("StorageKey").SetValue(model, storageKey5);
            var mapper3 = new Mapper_MobileSettingsDto_MobileSettings();

            model.MobileSettings = mapper3.ToModel(dto.MobileSettings);

            ToModelPostprocessing(dto, ref model);
            return(model);
        } // End ToModel Method