partial void ToModelPostprocessing(BudgetCollectionDto dto, ref BudgetCollection model)
        {
            var budgetCollection = model;

            dto.Budgets.ForEach(x => budgetCollection.Add(this.budgetMapper.ToModel(x)));
            dto.Buckets.ForEach(x => this.bucketRepo.GetOrCreateNew(x.Code, () => this.bucketMapper.ToModel(x)));
        }
 public void TestInitialise()
 {
     TestData = GetType().Assembly.ExtractEmbeddedResourceAsXamlObject<BudgetCollectionDto>("BudgetAnalyser.Engine.UnitTest.TestData.BudgetCollectionTestData.xml");
     var bucketRepo = new BucketBucketRepoAlwaysFind();
     var subject = new Mapper_BudgetCollectionDto_BudgetCollection(
         bucketRepo,
         new Mapper_BudgetBucketDto_BudgetBucket(new BudgetBucketFactory()), 
         new Mapper_BudgetModelDto_BudgetModel(bucketRepo));
     Result = subject.ToModel(TestData);
 }
        public void OutputBudgetModelTestData1()
        {
            var testData1 = new BudgetModelDto
            {
                EffectiveFrom = new DateTime(2014, 4, 28),
                LastModified = new DateTime(2014, 5, 2),
                LastModifiedComment = "The quick brown fox jumped over the lazy dog.",
                Name = "Foo data budget",
                Incomes = new List<IncomeDto>
                {
                    new IncomeDto
                    {
                        Amount = 2300.23M,
                        BudgetBucketCode = TestDataConstants.IncomeBucketCode,
                    },
                },
                Expenses = new List<ExpenseDto>
                {
                    new ExpenseDto
                    {
                        Amount = 350.11M,
                        BudgetBucketCode = TestDataConstants.PhoneBucketCode,
                    },
                    new ExpenseDto
                    {
                        Amount = 221.22M,
                        BudgetBucketCode = TestDataConstants.PowerBucketCode,
                    },
                },
            };

            var testData2 = new BudgetModelDto
            {
                EffectiveFrom = new DateTime(2012, 2, 29),
                LastModified = new DateTime(2013, 6, 6),
                LastModifiedComment = "Spatchcock.",
                Name = "Old data budget",
                Incomes = new List<IncomeDto>
                {
                    new IncomeDto
                    {
                        Amount = 2100.23M,
                        BudgetBucketCode = TestDataConstants.IncomeBucketCode,
                    },
                },
                Expenses = new List<ExpenseDto>
                {
                    new ExpenseDto
                    {
                        Amount = 310.11M,
                        BudgetBucketCode = TestDataConstants.PhoneBucketCode,
                    },
                    new ExpenseDto
                    {
                        Amount = 111.22M,
                        BudgetBucketCode = TestDataConstants.PowerBucketCode,
                    },
                },
            };

            var collection = new BudgetCollectionDto
            {
                Budgets = new List<BudgetModelDto> { testData1, testData2 },
                FileName = "Foo.xml",
            };

            string serialised = XamlServices.Save(collection);
            Console.WriteLine(serialised);
        }
 /// <summary>
 ///     Serialises the specified budget data.
 /// </summary>
 protected virtual string Serialise(BudgetCollectionDto budgetData)
 {
     return XamlServices.Save(budgetData);
 }
 partial void ToModelPostprocessing(BudgetCollectionDto dto, ref BudgetCollection model)
 {
     var budgetCollection = model;
     dto.Budgets.ForEach(x => budgetCollection.Add(this.budgetMapper.ToModel(x)));
     dto.Buckets.ForEach(x => this.bucketRepo.GetOrCreateNew(x.Code, () => this.bucketMapper.ToModel(x)));
 }
 partial void ToDtoPostprocessing(ref BudgetCollectionDto dto, BudgetCollection model)
 {
     dto.Buckets = this.bucketRepo.Buckets.Select(b => this.bucketMapper.ToDto(b)).ToList();
     dto.Budgets = model.ToList().Select(x => this.budgetMapper.ToDto(x)).ToList();
 }
 partial void ToDtoPostprocessing(ref BudgetCollectionDto dto, BudgetCollection model)
 {
     dto.Buckets = this.bucketRepo.Buckets.Select(b => this.bucketMapper.ToDto(b)).ToList();
     dto.Budgets = model.ToList().Select(x => this.budgetMapper.ToDto(x)).ToList();
 }