-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
153 lines (143 loc) · 5.5 KB
/
Program.cs
File metadata and controls
153 lines (143 loc) · 5.5 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
using Task;
class Program
{
static void Main()
{
var manager = new TaskManager();
manager.LoadTasks();
string userInput;
int selectedTask = 0;
bool exit = false;
Console.WriteLine("Welcome To Miley Task Manager");
Thread.Sleep(2000);
Console.Clear();
while (!exit)
{
Console.Clear();
Console.WriteLine("MILEY TASK MANAGER\n\n");
Console.WriteLine("1. View All Tasks\n2. Add A Task\n3.Complete A Task\n4. Delete Task\n5. Edit A Task\n6. Show Tasks By Filter\n7. Search Tasks\n8. Exit App");
userInput = Console.ReadLine();
switch (userInput)
{
case "1":
Console.Clear();
manager.ListTasks();
Console.ReadLine();
break;
case "2":
Console.Clear();
Console.WriteLine("Enter a task description below: ");
userInput = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(userInput))
{
Console.Clear();
manager.AddTask(userInput);
manager.SaveTask();
Console.WriteLine("New task added successfully!");
}
else
{
Console.WriteLine("Task not saved.");
}
Console.ReadLine();
break;
case "3":
Console.Clear();
Console.WriteLine("Enter task number below: ");
userInput = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(userInput) && int.TryParse(userInput, out selectedTask))
{
manager.CompleteTask(selectedTask);
manager.SaveTask();
Console.ReadLine();
}
else
{
Console.Clear();
Console.WriteLine("Invalid input entered.");
Thread.Sleep(500);
break;
}
break;
case "4":
Console.Clear();
Console.WriteLine("Enter task number below: ");
userInput = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(userInput) && int.TryParse(userInput, out selectedTask))
{
manager.DeleteTask(selectedTask);
Console.ReadLine();
}
else
{
Console.WriteLine("Invalid input entered");
Thread.Sleep(700);
break;
}
break;
case "5":
Console.Clear();
Console.WriteLine("Enter task number below: ");
userInput = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(userInput) && int.TryParse(userInput, out selectedTask))
{
Console.WriteLine("Enter new description: ");
userInput = Console.ReadLine();
if (userInput != null)
{
string newDescription = userInput;
manager.EditTask(selectedTask, newDescription);
manager.SaveTask();
}
}
else
{
Console.WriteLine("Invalid task number entered");
}
Console.ReadLine();
break;
case "6":
Console.Clear();
Console.WriteLine("Enter an option:\n1. View completed tasks \n2. View incomplete tasks");
userInput = Console.ReadLine();
int option;
if (int.TryParse(userInput, out option))
{
switch (option)
{
case 1:
manager.FilterTasks(true);
break;
case 2:
manager.FilterTasks(false);
break;
}
}
else
{
Console.WriteLine("Invalid option entered");
}
Console.ReadLine();
break;
case "7":
Console.Clear();
Console.WriteLine("Enter search term: ");
userInput = Console.ReadLine();
if (string.IsNullOrWhiteSpace(userInput))
{
Console.WriteLine("No search term entered");
}
else
{
manager.SearchTask(userInput);
}
Console.ReadLine();
break;
case "8":
Console.WriteLine("Exiting App..");
exit = true;
break;
}
}
}
}