|
@@ -9,7 +9,7 @@ namespace Reconstruction.Functions
|
|
|
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());
|
|
|
+ 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)
|
|
|
{
|
|
@@ -29,7 +29,6 @@ namespace Reconstruction.Functions
|
|
|
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();
|
|
@@ -40,34 +39,20 @@ namespace Reconstruction.Functions
|
|
|
"\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)
|
|
|
+ if(TaskCollection != 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)
|
|
|
+ while (true)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- statusID = int.Parse(Console.ReadLine());
|
|
|
+ id = int.Parse(Console.ReadLine());
|
|
|
+ task = (Task)Service.db.Tasks.Where(x => x.Id == id).SingleOrDefault();
|
|
|
break;
|
|
|
}
|
|
|
catch
|
|
@@ -75,18 +60,40 @@ namespace Reconstruction.Functions
|
|
|
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
|
|
|
+ if (task != null)
|
|
|
{
|
|
|
- Console.WriteLine("Operation abolished");
|
|
|
- }
|
|
|
+ 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");
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Console.WriteLine("User tasks are empty");
|
|
|
}
|
|
|
|
|
|
Console.ReadKey();
|
|
@@ -126,41 +133,50 @@ namespace Reconstruction.Functions
|
|
|
{
|
|
|
ObservableCollection<Task> TaskCollection = new ObservableCollection<Task>(Service.db.Tasks.ToList());
|
|
|
|
|
|
+ bool check = false ;
|
|
|
foreach (Task t in TaskCollection)
|
|
|
{
|
|
|
User user = (User)Service.db.Users.Where(u => u.Id == t.CreatorUserId).SingleOrDefault();
|
|
|
|
|
|
- if(t.StatusId != 1 && t.AccUserId == null)
|
|
|
+ if (t.StatusId != 1 && t.AccUserId == null)
|
|
|
{
|
|
|
Console.WriteLine("Title: " + t.Title +
|
|
|
"\nDescription: " + t.Description +
|
|
|
- "\nCreated by " + user.Login +
|
|
|
+ "\nCreated by " + user.Login +
|
|
|
"\nEnter " + t.Id + " to take this task\n");
|
|
|
+ check = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
int id = 0;
|
|
|
Task task;
|
|
|
-
|
|
|
- while (true)
|
|
|
+ if (check == true)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- id = int.Parse(Console.ReadLine());
|
|
|
- task = (Task)Service.db.Tasks.Where(x => x.Id == id).SingleOrDefault();
|
|
|
- break;
|
|
|
- }
|
|
|
- catch
|
|
|
+ while (true)
|
|
|
{
|
|
|
- Console.WriteLine("You entered a wrong value");
|
|
|
+ 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;
|
|
|
+ task.AccUserId = Service.LoggedUser.Id;
|
|
|
|
|
|
- Service.db.Tasks.Update(task);
|
|
|
- Service.db.SaveChanges();
|
|
|
+ Service.db.Tasks.Update(task);
|
|
|
+ Service.db.SaveChanges();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Console.WriteLine("No available tasks");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
Console.ReadKey();
|
|
|
}
|