|
@@ -5,6 +5,95 @@ namespace Reconstruction.Functions
|
|
|
{
|
|
|
public static class Display
|
|
|
{
|
|
|
+
|
|
|
+ public static void ShowCompletedTask()
|
|
|
+ {
|
|
|
+ Console.WriteLine("Tasks completed by " + Service.LoggedUser.Login);
|
|
|
+ ObservableCollection<Task> TaskCollection = new ObservableCollection<Task>(Service.db.Tasks.Where(x => x.AccUserId == Service.LoggedUser.Id && x.StatusId = 3).ToList());
|
|
|
+
|
|
|
+ foreach (Task t in TaskCollection)
|
|
|
+ {
|
|
|
+ User user = (User)Service.db.Users.Where(u => u.Id == t.CreatorUserId).SingleOrDefault();
|
|
|
+ Status status = (Status)Service.db.Statuses.Where(s => s.Id == t.StatusId).SingleOrDefault();
|
|
|
+
|
|
|
+ Console.WriteLine("Title: " + t.Title +
|
|
|
+ "\nDescription: " + t.Description +
|
|
|
+ "\nCreated by " + user.Login +
|
|
|
+ "\nStatus: " + status.Title + "\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ Console.ReadKey();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void ShowUsersTasks()
|
|
|
+ {
|
|
|
+ ObservableCollection<Task> TaskCollection = new ObservableCollection<Task>(Service.db.Tasks.Where(x => x.AccUserId == Service.LoggedUser.Id).ToList());
|
|
|
+
|
|
|
+ foreach (Task t in TaskCollection)
|
|
|
+ {
|
|
|
+ User user = (User)Service.db.Users.Where(u => u.Id == t.CreatorUserId).SingleOrDefault();
|
|
|
+ Status status = (Status)Service.db.Statuses.Where(s => s.Id == t.StatusId).SingleOrDefault();
|
|
|
+
|
|
|
+ Console.WriteLine("Title: " + t.Title +
|
|
|
+ "\nDescription: " + t.Description +
|
|
|
+ "\nCreated by " + user.Login +
|
|
|
+ "\nStatus: " + status.Title +
|
|
|
+ "\nEnter " + t.Id + " to change its status\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ int id = 0;
|
|
|
+ Task task;
|
|
|
+
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ id = int.Parse(Console.ReadLine());
|
|
|
+ task = (Task)Service.db.Tasks.Where(x => x.Id == id).SingleOrDefault();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ Console.WriteLine("You entered a wrong value");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(task != null)
|
|
|
+ {
|
|
|
+ Console.WriteLine("Enter:\n1 - to set task 'incompleted'\n2 - to set task 'in progress'\n3 - to set task 'completed'\n0 - to abolish this operation\n");
|
|
|
+ int statusID;
|
|
|
+
|
|
|
+ while(true)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ statusID = int.Parse(Console.ReadLine());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ Console.WriteLine("You entered a wrong value");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(statusID != 0 && statusID < 4)
|
|
|
+ {
|
|
|
+ task.StatusId = statusID;
|
|
|
+ Service.db.Tasks.Update(task);
|
|
|
+ Service.db.SaveChanges();
|
|
|
+ Console.WriteLine("Operation performed successfully");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Console.WriteLine("Operation abolished");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Console.ReadKey();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static void ShowUserList()
|
|
|
{
|
|
|
Console.WriteLine("Login |" + " Lastname |" + " Firstname |" + " Middlename ");
|
|
@@ -41,20 +130,38 @@ namespace Reconstruction.Functions
|
|
|
{
|
|
|
User user = (User)Service.db.Users.Where(u => u.Id == t.CreatorUserId).SingleOrDefault();
|
|
|
|
|
|
- if(user == null)
|
|
|
- {
|
|
|
- user.Login = "No user attached";
|
|
|
- }
|
|
|
-
|
|
|
- if(t.StatusId == 1)
|
|
|
+ if(t.StatusId != 1 && t.AccUserId == null)
|
|
|
{
|
|
|
Console.WriteLine("Title: " + t.Title +
|
|
|
"\nDescription: " + t.Description +
|
|
|
- "\nCreated by " + user.Login + "\n");
|
|
|
+ "\nCreated by " + user.Login +
|
|
|
+ "\nEnter " + t.Id + " to take this task\n");
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ int id = 0;
|
|
|
+ Task task;
|
|
|
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ id = int.Parse(Console.ReadLine());
|
|
|
+ task = (Task)Service.db.Tasks.Where(x => x.Id == id).SingleOrDefault();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ Console.WriteLine("You entered a wrong value");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ task.AccUserId = Service.LoggedUser.Id;
|
|
|
+
|
|
|
+ Service.db.Tasks.Update(task);
|
|
|
+ Service.db.SaveChanges();
|
|
|
+
|
|
|
Console.ReadKey();
|
|
|
}
|
|
|
|