Skip to content

Commit 498a9f7

Browse files
authored
Update Program.cs
1 parent a2f4011 commit 498a9f7

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

AdventureData/Program.cs

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
1-
using System;
1+
using Microsoft.Extensions.Configuration;
2+
using System;
3+
using System.IO;
4+
using AdventureData.DAL;
25

36
namespace AdventureData
47
{
58
class Program
69
{
10+
private static IConfiguration _iconfiguration;
711
static void Main(string[] args)
812
{
9-
Console.WriteLine("Hello World!");
13+
GetAppSettingsFile();
14+
ShowAdventureDepartments();
15+
Console.WriteLine("Press any key to stop.");
16+
Console.ReadKey();
17+
}
18+
19+
static void GetAppSettingsFile()
20+
{
21+
var builder = new ConfigurationBuilder()
22+
.SetBasePath(Directory.GetCurrentDirectory())
23+
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
24+
_iconfiguration = builder.Build();
25+
}
26+
static void ShowAdventureDepartments()
27+
{
28+
var deptDAL = new DepartmentDAL(_iconfiguration);
29+
var lstDepartment = deptDAL.GetAllDepartments();
30+
lstDepartment.ForEach(item =>
31+
{
32+
Console.WriteLine($"DeptID: {item.DepartmentID}" +
33+
$" Name: {item.Name}" +
34+
$" Grp Name: {item.GroupName}" +
35+
$" Date: {item.ModifiedDate.ToShortDateString()}");
36+
});
1037
}
1138
}
1239
}

0 commit comments

Comments
 (0)