Skip to content

Commit 65d1e44

Browse files
committed
LP6 M1 starter updates
1 parent 43bd8e9 commit 65d1e44

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

DownloadableCodeProjects/LP6_implement-delegates-events/Delegates/Starter/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ static async Task Main()
1313
Bank bank = new Bank();
1414

1515
// Generate 2 years of transactions for 50 customers
16-
GenerateCustomerDataAsync;
16+
await CreateDataLogsAsync.GenerateCustomerDataAsync();
1717

1818
// Load the customer data asynchronously from the file
1919
var asyncLoadTask = LoadCustomerLogsAsync.ReadCustomerDataAsync(bank);

DownloadableCodeProjects/LP6_implement-delegates-events/Delegates/Starter/Services/CreateDataLogsAsync.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ public static async Task GenerateCustomerDataAsync()
2323
var approvedCustomers = await ApprovedCustomersLoaderAsync.LoadApprovedNamesAsync();
2424

2525
string configDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), "Config");
26+
string customersDirectoryPath = Path.Combine(configDirectoryPath, "Customers");
27+
string accountsDirectoryPath = Path.Combine(configDirectoryPath, "Accounts");
28+
string transactionsDirectoryPath = Path.Combine(configDirectoryPath, "Transactions");
29+
30+
// Delete the Customers, Accounts, and Transactions directories if they exist
31+
if (Directory.Exists(customersDirectoryPath))
32+
{
33+
Directory.Delete(customersDirectoryPath, true);
34+
}
35+
36+
if (Directory.Exists(accountsDirectoryPath))
37+
{
38+
Directory.Delete(accountsDirectoryPath, true);
39+
}
40+
41+
if (Directory.Exists(transactionsDirectoryPath))
42+
{
43+
Directory.Delete(transactionsDirectoryPath, true);
44+
}
2645

2746
foreach (var customer in approvedCustomers)
2847
{

DownloadableCodeProjects/LP6_implement-delegates-events/Delegates/Starter/Services/JsonRetrievalAsync.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public static async Task<IEnumerable<BankCustomer>> LoadAllCustomersAsync(Bank b
6767
List<BankCustomer> customers = new List<BankCustomer>();
6868
foreach (var filePath in Directory.GetFiles(Path.Combine(directoryPath, "Customers"), "*.json"))
6969
{
70-
customers.Add(await LoadBankCustomerAsync(bank, filePath, accountsDirectoryPath, transactionsDirectoryPath));
70+
// the LoadBankCustomerAsync method will add the customer to the bank
71+
await LoadBankCustomerAsync(bank, filePath, accountsDirectoryPath, transactionsDirectoryPath);
7172
}
7273
return customers;
7374
}

0 commit comments

Comments
 (0)