A Dto object to persist a Budget Model.
 partial void ToDtoPostprocessing(ref BudgetModelDto dto, BudgetModel model)
 {
     var mapper3 = new Mapper_ExpenseDto_Expense(this.bucketRepo);
     List<ExpenseDto> expenses8 = model.Expenses.Select(mapper3.ToDto).ToList();
     dto.Expenses = expenses8;
     var mapper4 = new Mapper_IncomeDto_Income(this.bucketRepo);
     List<IncomeDto> incomes9 = model.Incomes.Select(mapper4.ToDto).ToList();
     dto.Incomes = incomes9;
 }
        partial void ToDtoPostprocessing(ref BudgetModelDto dto, BudgetModel model)
        {
            var mapper3 = new Mapper_ExpenseDto_Expense(this.bucketRepo);
            List <ExpenseDto> expenses8 = model.Expenses.Select(mapper3.ToDto).ToList();

            dto.Expenses = expenses8;
            var mapper4 = new Mapper_IncomeDto_Income(this.bucketRepo);
            List <IncomeDto> incomes9 = model.Incomes.Select(mapper4.ToDto).ToList();

            dto.Incomes = incomes9;
        }
 partial void ToModelPostprocessing(BudgetModelDto dto, ref BudgetModel model)
 {
     var modelType = model.GetType();
     var mapper1 = new Mapper_ExpenseDto_Expense(this.bucketRepo);
     List<Expense> expenses2 = dto.Expenses.Select(mapper1.ToModel).ToList();
     model.LastModified = dto.LastModified ?? DateTime.Now;
     modelType.GetProperty("Expenses").SetValue(model, expenses2);
     var mapper2 = new Mapper_IncomeDto_Income(this.bucketRepo);
     List<Income> incomes3 = dto.Incomes.Select(mapper2.ToModel).ToList();
     modelType.GetProperty("Incomes").SetValue(model, incomes3);
 }
        partial void ToModelPostprocessing(BudgetModelDto dto, ref BudgetModel model)
        {
            var            modelType = model.GetType();
            var            mapper1   = new Mapper_ExpenseDto_Expense(this.bucketRepo);
            List <Expense> expenses2 = dto.Expenses.Select(mapper1.ToModel).ToList();

            model.LastModified = dto.LastModified ?? DateTime.Now;
            modelType.GetProperty("Expenses").SetValue(model, expenses2);
            var           mapper2  = new Mapper_IncomeDto_Income(this.bucketRepo);
            List <Income> incomes3 = dto.Incomes.Select(mapper2.ToModel).ToList();

            modelType.GetProperty("Incomes").SetValue(model, incomes3);
        }
        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);
        }