/// <summary> /// Creates a new budget analyser database graph. /// </summary> /// <exception cref="System.ArgumentNullException"></exception> public async Task <ApplicationDatabase> CreateNewAsync(string storageKey) { if (storageKey.IsNothing()) { throw new ArgumentNullException(nameof(storageKey)); } var path = Path.Combine(Path.GetDirectoryName(storageKey) ?? string.Empty, Path.GetFileNameWithoutExtension(storageKey) ?? string.Empty); var storageRoot = new BudgetAnalyserStorageRoot { BudgetCollectionRootDto = new StorageBranch { Source = path + ".Budget.xml" }, LedgerBookRootDto = new StorageBranch { Source = path + ".LedgerBook.xml" }, LedgerReconciliationToDoCollection = new List <ToDoTaskDto>(), MatchingRulesCollectionRootDto = new StorageBranch { Source = path + ".MatchingRules.xml" }, StatementModelRootDto = new StorageBranch { Source = path + ".Transactions.csv" } }; var serialised = Serialise(storageRoot); await WriteToDiskAsync(storageKey, serialised); var appDb = this.mapper.ToModel(storageRoot); appDb.FileName = storageKey; return(appDb); }
partial void ToDtoPostprocessing(ref BudgetAnalyserStorageRoot dto, ApplicationDatabase model) { dto.BudgetCollectionRootDto = new StorageBranch { Source = model.BudgetCollectionStorageKey }; dto.LedgerBookRootDto = new StorageBranch { Source = model.LedgerBookStorageKey }; var mapper = new Mapper_ListToDoTaskDto_ToDoCollection(); dto.LedgerReconciliationToDoCollection = mapper.ToDto(model.LedgerReconciliationToDoCollection); dto.MatchingRulesCollectionRootDto = new StorageBranch { Source = model.MatchingRulesCollectionStorageKey }; dto.StatementModelRootDto = new StorageBranch { Source = model.StatementModelStorageKey }; }
partial void ToModelPostprocessing(BudgetAnalyserStorageRoot dto, ref ApplicationDatabase model) { model.BudgetCollectionStorageKey = dto.BudgetCollectionRootDto.Source; model.LedgerBookStorageKey = dto.LedgerBookRootDto.Source; var taskMapper = new Mapper_ListToDoTaskDto_ToDoCollection(); model.LedgerReconciliationToDoCollection = taskMapper.ToModel(dto.LedgerReconciliationToDoCollection); model.MatchingRulesCollectionStorageKey = dto.MatchingRulesCollectionRootDto.Source; model.StatementModelStorageKey = dto.StatementModelRootDto.Source; }
public void TestInitialise() { var todoCollection = new ToDoCollection(); todoCollection.Add(new ToDoTask("Foo1")); todoCollection.Add(new ToDoTask("Foo2", false, false)); this.testData = new ApplicationDatabase(); PrivateAccessor.SetProperty(this.testData, "BudgetCollectionStorageKey", "Budget.xml"); PrivateAccessor.SetProperty(this.testData, "FileName", "C:\\Foo\\TestData.bax"); PrivateAccessor.SetProperty(this.testData, "LedgerBookStorageKey", "Ledger.xml"); PrivateAccessor.SetProperty(this.testData, "MatchingRulesCollectionStorageKey", "Rules.xml"); PrivateAccessor.SetProperty(this.testData, "StatementModelStorageKey", "Statement.xml"); PrivateAccessor.SetProperty(this.testData, "LedgerReconciliationToDoCollection", todoCollection); var subject = new Mapper_BudgetAnalyserStorageRoot_ApplicationDatabase(); this.result = subject.ToDto(this.testData); }
public void TestInitialise() { this.testData = new BudgetAnalyserStorageRoot { BudgetCollectionRootDto = new StorageBranch { Source = "Budget.xml" }, LedgerBookRootDto = new StorageBranch { Source = "Ledger.xml" }, MatchingRulesCollectionRootDto = new StorageBranch { Source = "Rules.xml" }, StatementModelRootDto = new StorageBranch { Source = "Statement.xml" }, LedgerReconciliationToDoCollection = new List<ToDoTaskDto> { new ToDoTaskDto { CanDelete = true, Description = "Foo1", SystemGenerated = false }, new ToDoTaskDto { CanDelete = false, Description = "Foo2", SystemGenerated = true } } }; var subject = new Mapper_BudgetAnalyserStorageRoot_ApplicationDatabase(); this.result = subject.ToModel(this.testData); }
/// <summary> /// Creates a new budget analyser database graph. /// </summary> /// <exception cref="System.ArgumentNullException"></exception> public async Task<ApplicationDatabase> CreateNewAsync(string storageKey) { if (storageKey.IsNothing()) { throw new ArgumentNullException(nameof(storageKey)); } var path = Path.Combine(Path.GetDirectoryName(storageKey) ?? string.Empty, Path.GetFileNameWithoutExtension(storageKey) ?? string.Empty); var storageRoot = new BudgetAnalyserStorageRoot { BudgetCollectionRootDto = new StorageBranch { Source = path + ".Budget.xml" }, LedgerBookRootDto = new StorageBranch { Source = path + ".LedgerBook.xml" }, LedgerReconciliationToDoCollection = new List<ToDoTaskDto>(), MatchingRulesCollectionRootDto = new StorageBranch { Source = path + ".MatchingRules.xml" }, StatementModelRootDto = new StorageBranch { Source = path + ".Transactions.csv" } }; var serialised = Serialise(storageRoot); await WriteToDiskAsync(storageKey, serialised); var appDb = this.mapper.ToModel(storageRoot); appDb.FileName = storageKey; return appDb; }
/// <summary> /// Serialises the specified budget analyser database to a Xaml string. /// </summary> /// <param name="budgetAnalyserDatabase">The budget analyser database.</param> protected virtual string Serialise(BudgetAnalyserStorageRoot budgetAnalyserDatabase) { return(XamlServices.Save(budgetAnalyserDatabase)); }
/// <summary> /// Serialises the specified budget analyser database to a Xaml string. /// </summary> /// <param name="budgetAnalyserDatabase">The budget analyser database.</param> protected virtual string Serialise(BudgetAnalyserStorageRoot budgetAnalyserDatabase) { return XamlServices.Save(budgetAnalyserDatabase); }