/// <summary>Export the data in a JSON format to a file specified in fileName. /// </summary> /// <param name="fileName">Name of the file.</param> public void Export(string fileName) { var database = new DataBaseContents { Users = new List <User> { mAuthorizationService.CurrentUser }, Entries = mEntryDataService.GetAll(), Rules = mProcessingRuleDataService.GetAll(), Transactions = mTransactionDataService.GetAll() }; // Clear all child entries to prevent circulair reference when exporting to JSON. foreach (var databaseEntry in database.Entries) { databaseEntry.ChildEntries?.Clear(); databaseEntry.ParentEntry = null; } using (var file = File.CreateText(fileName)) { var serializer = new JsonSerializer(); serializer.Serialize(file, database); } }
/// <summary> /// </summary> private void ShowPreview() { MatchingTransactions.Clear(); if (mSelectedRule == null) { return; } var previewedRule = Mapper.Map <ProcessingRule>(mSelectedRule); var transactions = mTransactionDataService.GetAll(); foreach (var transaction in transactions) { if (previewedRule.AppliesTo(transaction)) { MatchingTransactions.Add(transaction); } } }