-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
81 lines (61 loc) · 2.45 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using NLog.Web;
using System.IO;
using System.Collections.Generic;
namespace TicketSystem
{
class Program
{
// create static instance of Logger
private static NLog.Logger logger = NLogBuilder.ConfigureNLog(Directory.GetCurrentDirectory() + "\\nlog.config").GetCurrentClassLogger();
static void Main(string[] args)
{
string ticketFilePath = Directory.GetCurrentDirectory() + "\\tickets.csv";
logger.Info("Program started");
TicketFile ticketFile = new TicketFile(ticketFilePath);
string choice = "";
do
{
Console.WriteLine("1) Add Ticket");
Console.WriteLine("2) Display All Tickets");
Console.WriteLine("Enter to quit");
choice = Console.ReadLine();
logger.Info("User choice: {Choice}", choice);
if (choice == "1")
{
Ticket ticket = new Ticket();
Console.WriteLine("Enter a summary -");
ticket.summary = Console.ReadLine();
Console.WriteLine("Enter a priority level -");
ticket.priority = Console.ReadLine();
Console.WriteLine("Enter your name -");
ticket.submitter = Console.ReadLine();
Console.WriteLine("Enter who this is assigned to -");
ticket.assigned = Console.ReadLine();
String input;
do
{
Console.WriteLine("Enter a watcher (or done to quit)");
input = Console.ReadLine();
if (input != "done" && input.Length > 0)
{
ticket.watching.Add(input);
}
} while (input != "done");
if (ticket.watching.Count == 0)
{
ticket.watching.Add("(no one watching)");
}
ticketFile.AddTicket(ticket);
}
else if (choice == "2")
{
foreach(Ticket m in ticketFile.Tickets)
{Console.WriteLine(m.Display());
}
}
} while (choice == "1" || choice == "2");
logger.Info("Program ended");
}
}
}