Exemple #1
0
 private Task(
     IDictionary <uint, Task> allTasks,
     uint id,
     uint parentId
     )
 {
     this.allTasks             = allTasks;
     this.parentId             = parentId;
     Id                        = id;
     hasOpenSubtasks           = new Lazy <bool>(() => Subtasks.Any(t => !t.IsExplicitlyComplete));
     hasCompletedAncestorTasks = new Lazy <bool>(() =>
     {
         return(Parent != null &&
                (Parent.IsExplicitlyComplete || Parent.HasCompletedAncestorTasks));
     });
     dependencyTasks = new Lazy <IDictionary <uint, Task> >(() =>
     {
         return(allTasks
                .Where(kvp => dependencyIds.Contains(kvp.Key))
                .ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
     });
     hasOpenDependencies = new Lazy <bool>(() =>
     {
         return(DependencyTasks.Values.Any(t => !t.IsComplete));
     });
 }
Exemple #2
0
 private bool SaveDetailCanExecute()
 {
     return(SelectedProject != null &&
            !SelectedProject.HasErrors &&
            Subtasks.All(pn => !pn.HasErrors) &&
            (HasChanges || !InEditMode));
 }
Exemple #3
0
        /// <summary>
        /// Deletes the specified subtask from the collection.
        /// </summary>
        /// <param name="subtask">The subtask to delete.</param>
        private async Task DeleteSubtask(SubtaskViewModel subtask)
        {
            if (subtask == null)
            {
                return;
            }

            // Unsubscribe from property changed event
            subtask.PropertyChanged -= SubtaskViewModel_PropertyChanged;

            // Delete item from database
            var success = await _repo.DeleteSubtask(subtask);

            // If failed, set message and return
            if (!success)
            {
                SetMessage("Deletion failed. Try again later.");
                return;
            }

            // Remove item from view
            Subtasks.Remove(subtask);

            // Set message
            SetMessage("Subtask deleted.");
        }
Exemple #4
0
        /// <summary>
        /// Adds a new subtask to the collection.
        /// </summary>
        private async Task AddSubtask()
        {
            // New Subtask
            SubtaskViewModel subtask = new SubtaskViewModel()
            {
                Name = this.NewSubtaskName
            };

            // Subscribe to property changed event for new subtask
            subtask.PropertyChanged += SubtaskViewModel_PropertyChanged;

            // Add subtask to database
            await _repo.AddSubtask(subtask, this.Id).ContinueWith(async p =>
            {
                subtask.Id         = await p;
                subtask.TodoTaskId = this.Id;
            });

            // Add item to view
            Subtasks.Add(subtask);

            subtask.IsCompleted = false;

            // Reset new subtask
            NewSubtaskName  = null;
            NewSubtaskAdded = true;
            NewSubtaskAdded = false;
        }
Exemple #5
0
 public TaskExtra GetExtra(Wunderlist.TodoTask task)
 {
     return(new TaskExtra(
                Lists[task.ListId],
                Subtasks.TryGet(task.Id),
                Reminders.TryGet(task.Id),
                Notes.TryGet(task.Id),
                SubtaskPositions.TryGet(task.Id)));
 }
Exemple #6
0
        public ActionResult DeleteSubtask(int Id, string ProjectName)
        {
            Subtasks subtask = context.Subtasks.Find(Id);

            subtask.is_Deleted = true;
            context.SaveChanges();

            return(PartialView("Display_Subtask", GetSutask(ProjectName)));
        }
Exemple #7
0
        public virtual void Progress(float dT)
        {
            if (CurrentTask == null)
            {
                if (Subtasks.Count > 0)
                {
                    CurrentTask       = (Subtasks.Dequeue());
                    CurrentTask.Actor = this.Actor;
                    CurrentTask.State = TaskState.InProgress;
                    CurrentTask.Initialize();
                }
                return;
            }
            switch (CurrentTask.State)
            {
            case TaskState.Enqueued:
            {
                CurrentTask.State = TaskState.InProgress;
                CurrentTask.Initialize();
                break;
            }

            case TaskState.Complete:
            {
                CurrentTask.CompletedAction?.Invoke();
                CurrentTask = null;
                if (Subtasks.Count > 0)
                {
                    CurrentTask       = (Subtasks.Dequeue());
                    CurrentTask.Actor = this.Actor;
                    CurrentTask.State = TaskState.InProgress;
                    CurrentTask.Initialize();
                }
                else
                {
                    this.State = TaskState.Complete;
                }
                break;
            }

            case TaskState.InProgress:
            {
                CurrentTask.Progress(dT);
                break;
            }

            case TaskState.Suspended:
            {
                CurrentTask.State = TaskState.Enqueued;

                this.State         = TaskState.Suspended;
                this.SuspendReason = this.CurrentTask.SuspendReason;
                Console.Write(this.Actor.Name + " cancels " + this.CurrentTask.Description + ": " + CurrentTask.SuspendReason);
                break;
            }
            }
        }
        public void AddSubtask(TaskItem item)
        {
            if (Subtasks is null)
            {
                Subtasks = new List <TaskItem>();
            }

            Subtasks.Add(item);
        }
Exemple #9
0
        public ActionResult Create_Subtask(string Subtask, string Project)
        {
            Subtasks subtask = new Subtasks();

            subtask.is_Deleted   = false;
            subtask.Updated_date = DateTime.Now;
            subtask.Project_Name = Project;
            subtask.Subtask      = Subtask;
            context.Subtasks.Add(subtask);
            context.SaveChanges();


            return(PartialView("Display_Subtask", GetSutask(Project)));
        }
Exemple #10
0
        private void InitialiseProjectSubtasks(ICollection <ProjectSubtask> subtasks)
        {
            foreach (var wrapper in Subtasks)
            {
                wrapper.PropertyChanged -= Wrapper_PropertyChanged;
            }

            Subtasks.Clear();
            foreach (var projectSubtask in subtasks)
            {
                var wrapper = new SubTaskWrapper(projectSubtask);
                Subtasks.Add(wrapper);
                wrapper.PropertyChanged += Wrapper_PropertyChanged;
            }
        }